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

            Bug ID: 117333
           Summary: structure copy with flexible array member
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbeulich at suse dot com
  Target Milestone: ---

Created attachment 59476
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59476&action=edit
example code

There are two issues.

First, the attached example causes an ICE (at least at -O2) on x86-64 (if that
matters).

Second, removing either half of the conditional in test() allows compilation to
succeed, yet the generated code then has accesses beyond sizeof(struct s). Imo
clause 22 in C99 section 6.2.1 gives a close enough example, where it is
explicitly stated that nothing past sizeof() would be copied.

As an aside, gcc5 rejected the assignment with "invalid use of flexible array
member". That's still wrong imo, but better than an ICE.

Reply via email to