https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109863
Bug ID: 109863 Summary: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yann at droneaud dot fr Target Milestone: --- I've noted some discrepancies in the flex array initialization support: /* https://godbolt.org/z/9er5G9G15 */ struct s { char i; char c[]; }; extern void t(const struct s*); void f(void) { // ERROR: non-static initialization of a flexible array member const struct s c0 = { .c = "0", }; t(&c0); // ERROR: non-static initialization of a flexible array member const struct s *const c1 = &(const struct s) { .c = "1", }; t(c1); // OK const struct s *const c2 = &(constexpr struct s) { .c = "2", }; t(c2); // ERROR: initializer element is not constant static const struct s *const c3 = &(constexpr struct s) { .c = "3", }; t(c3); // OK static const struct s *const c4 = &(static constexpr struct s) { .c = "4", }; t(c4); } AFAICT constexpr is not supposed to also mean static storage at the block level, so flex array in c2 is initialized in a non-static way ... Then I would be happy if GCC could be enhanced to not reject c0 and c1 initialization. But I fear the opposite will happen, and GCC will reject c2 initialization too :)