From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 45033385735C; Mon, 15 May 2023 16:29:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45033385735C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684168166; bh=BkUV2ZrHvzBTNgDHUhkdQfcG3AbLWfMk2iqN1BVOltw=; h=From:To:Subject:Date:From; b=sGv5cJ99v1z3RSRfF7fHpDcMeGQEwgmhUJ0UTv29WsqfWBhURNsH85LqGtByhhAGl 8Bg+DGhdsmaWO3lxw66msk/krY5fQOVpyFpYdnI+awV9CZaShiHk0LNFS1v5KXcI02 RJfuiOz3K12LZbEd0/8R9jwBomR63vfv1gI0NCto= From: "yann at droneaud dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109863] New: RFE: more consistent flex array initialization: lift static storage requirement in gnu2x Date: Mon, 15 May 2023 16:29:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yann at droneaud dot fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109863 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 =3D { .c =3D "0", }; t(&c0); // ERROR: non-static initialization of a flexible array member const struct s *const c1 =3D &(const struct s) { .c =3D "1", }; t(c1); // OK const struct s *const c2 =3D &(constexpr struct s) { .c =3D "2", }; t(c2); // ERROR: initializer element is not constant static const struct s *const c3 =3D &(constexpr struct s) { .c =3D = "3", }; t(c3); // OK static const struct s *const c4 =3D &(static constexpr struct s) { = .c =3D "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 :)=