https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93121
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #48883|0 |1 is obsolete| | Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2020-07-17 Ever confirmed|0 |1 --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 48890 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48890&action=edit gcc11-pr93121.patch Untested full patch, zero sized arrays work fine, but flexible arrays don't and it is unclear what exactly do we want to do with them. Treat them always as zero sized arrays? Or have a special case if the argument is a reference to a VAR_DECL or VAR_DECL itself which has type with flexible array member and in that case assume the flexible array size from the initializer? struct A { int a; int b[]; }; struct B { int a; int b[0]; }; constexpr A a = { 1, {} }; constexpr B b = { 2, {} }; static_assert (__builtin_bit_cast (int, a) == 1, ""); static_assert (__builtin_bit_cast (int, b) == 2, ""); static_assert ((__builtin_bit_cast (B, a)).a == 1, ""); static_assert ((__builtin_bit_cast (A, b)).a == 2, "");