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

            Bug ID: 120953
           Summary: Accepts invalid with range for
           Product: gcc
           Version: 16.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 b; short c; };
constexpr S d = { 1, 2, 3 }, e = { 4, 5, 6 }, f = { 7, 8, 9 };

void
foo ()
{
  long long r = 0;
  constexpr S h[] = { d, e, f };
  for (static auto &g : h)
    r += g.a + g.b + g.c;
}

is accepted by g++ and rejected by clang++:
loop variable 'g' may not be declared 'static'
https://eel.is/c++draft/stmt.ranged#2
says that only type-specifier and constexpr can be present, so wonder what all
we are missing to complain about and whether because we've been accepting it it
should be just pedwarn or error.

Reply via email to