This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-08-11
(From submissions #725 and #730.)
The rewrite of iterating expansion statements contains:
static constexpr auto iter = begin + i;where the type of i is unspecified, but overload resolution of + depends on the type of i.
Furthermore, the rewrite contains
for (auto i = begin ; i != end ; ++i, ++result);which might invoke an overloaded comma operator, which is undesirable.
Furthermore, because of the use of static in the rewrite, the example in 8.7 [stmt.expand] paragraph 7 is ill-formed.
Possible resolution:
Change in 8.7 [stmt.expand] bullet 5.2 as follows:
Otherwise, if S is an iterating expansion statement, S is equivalent to:{ init-statementwhere N is the result of evaluating the expressionstaticconstexpr auto&& range = expansion-initializer ;staticconstexpr auto begin = begin-expr; // see 8.6.5 [stmt.ranged]staticconstexpr auto end = end-expr; // see 8.6.5 [stmt.ranged] S0 . . . SN-1 }[] consteval { std::ptrdiff_t result = 0; for (auto i = begin ; i != end ; ++iand Si is, ++result) ++result; return result; // distance from begin to end }(){The variables range , begin , end , and iter are defined for exposition only. The identifier i is considered to be a prvalue of type decltype(begin - begin); the program is ill-formed if i is not representable as such a value. [Note 1 : The instantiation is ill-formed if range is not a constant expression (7.7 [expr.const]). -- end note]staticconstexpr auto iter = begin +ii; for-range-declaration = *iter ; compound-statement }
No change in 8.7 [stmt.expand] paragraph 7:
[ Example 2:
consteval int f() {
constexpr std::array<int, 3> arr {1, 2, 3};
int result = 0;
template for (constexpr int s : arr) { // OK, iterating expansion statement
result += sizeof(char[s]);
}
return result;
}
static_assert(f() == 6);
—end example]