This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-01-23


3149. Rvalues in destructuring expansion statements

Section: 8.7  [stmt.expand]     Status: open     Submitter: Barry Revzin     Date: 2026-01-14

(From submission #835.)

Consider:

  auto f() -> std::tuple<int, int&, int&&>;

  auto g() -> void {
    template for (auto&& elem : f()) {
      ;
    }
  }

The type of elem is int& in each iteration, but the intent of P1306R5 was that the first and third iteration yield int&& instead.

Possible resolution:

Change in 8.7 [stmt.expand] bullet 5.3 as follows:

... where N is the structured binding size of the type of the expansion-initializer and Si is
  {
    for-range-declaration = ui vi;
    compound-statement
  }
If the expansion-initializer is an lvalue, then vi is ui; otherwise, vi is static_cast<decltype(ui)&&>(ui).