https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120039

            Bug ID: 120039
           Summary: [15/16 Regression] Structured binding in condition ICE
                    since r15-1793
           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: ---

struct S {
  int a; long long b; short c;
  explicit operator bool () const noexcept { return true; }
};

template <int N>
void
foo ()
{
  S s = S { 1, 2, 3 };
  if (auto [sx, sy, sz] : s)
    ;
}

int
main ()
{
  foo <0> ();
}

ICEs starting with r15-1793-gf30bdb1f2d79fd787 :
/opt/notnfs/gcc-bisect/obj/gcc/cc1plus.r16-304 -quiet decomp14.C -std=c++26
decomp14.C: In function ‘void foo()’:
decomp14.C:11:25: error: expected initializer before ‘:’ token
[-Wtemplate-body]
   11 |   if (auto [sx, sy, sz] : s)
      |                         ^
decomp14.C:11:24: error: expected ‘)’ before ‘:’ token [-Wtemplate-body]
   11 |   if (auto [sx, sy, sz] : s)
      |      ~                 ^~
      |                        )
decomp14.C: In instantiation of ‘void foo() [with int N = 0]’:
decomp14.C:18:11:   required from here
   18 |   foo <0> ();
      |   ~~~~~~~~^~
decomp14.C:11:3: internal compiler error: Segmentation fault
   11 |   if (auto [sx, sy, sz] : s)
      |   ^~
0x3079199 internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0x11d0296 crash_signal
        ../../gcc/toplev.cc:321
0x402ebd tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/tree.h:3691
0x43e5b2 get_identifier_kind(tree_node*)
        ../../gcc/cp/cp-tree.h:1315
0x6b2829 lookup_name(tree_node*, LOOK_where, LOOK_want)
        ../../gcc/cp/name-lookup.cc:8058
0x6b2c71 lookup_name(tree_node*)
        ../../gcc/cp/name-lookup.cc:8143
0x7cc03e tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/cp/pt.cc:21987
0x7c0fd1 tsubst_stmt
        ../../gcc/cp/pt.cc:20024

Reply via email to