[Bug c++/127046] [16/17 Regression] Trailing array element loses its initializer when the constexpr function it's declared in is const-evaluated since r16-3022-gbc42128330c

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 25 06:11:44 GMT 2026


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

Drea Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-08-25
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.  It is not only the last one but anything past element 2.

E.g.
```

struct T { char padding[4] = {'x'};
 constexpr ~T(){}
  };
constexpr bool test() {
  T array[10] = {};
  return array[0].padding[0]=='x' && array[1].padding[0]=='x'
   && array[2].padding[0]=='x';
}
int main() { return test() ? 0 : 1; }
```

Will fail too.


More information about the Gcc-bugs mailing list