https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118833
Bug ID: 118833 Summary: [15 Regression] ICE with structured binding as condition of while/for loop since r15-7426 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- My PR86769 fix regressed the following testcase, it now ICEs: // P0963R3 - Structured binding declaration as a condition // { dg-do compile { target c++11 } } // { dg-options "" } namespace std { template<typename T> struct tuple_size; template<int, typename> struct tuple_element; } struct S { S () : s (0) {} S (int x) : s (x) {} S (const S &x) : s (x.s) {} ~S () {} int s; }; struct T { S a, b, c; ~T () {} explicit operator bool () const noexcept { return a.s == b.s; } template <int I> S get () { return I ? a : b; } }; template<> struct std::tuple_size<T> { static const int value = 2; }; template<int I> struct std::tuple_element<I,T> { using type = S; }; void foo (T t, bool x) { while (auto [ i, j ] = T { 1, 1, 3 }) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } } { if (x) break; } } void bar (T t, bool x) { for (int cnt = 0; auto [ i, j ] = T { 2, 2, 4 }; ++cnt) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } } { if (x) break; } } The assumption that there is no or just a single cleanup isn't true for structured bindings used as a condition, each name in the structured binding can have its own cleanup.