[Bug middle-end/36987] Truncated C struct data initializer with variable size trailing array
--- Comment #4 from howard dot thomson at dial dot pipex dot com 2008-07-31 19:53 --- OK Thanks to all. I did look for previous reports, honest! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36987
[Bug c/36987] Truncated C struct data initializer with variable size trailing array
--- Comment #1 from howard dot thomson at dial dot pipex dot com 2008-07-31 12:50 --- Created an attachment (id=15985) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15985&action=view) test for unexpected C struct field alteration Due to the variable sized component of the struct initializer not being emitted, assignment to the single element of that initializer results in the following data structure being unexpectedly altered. gcc is 4.0.1 (Apple Computer, Inc. build 5449) on an X86_64 OpenSUSE 10.3 system. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36987
[Bug c/36987] New: Truncated C struct data initializer with variable size trailing array
An initializer for a C struct with a variable sized last component is accepted, but the data generated excludes the variable sized component. struct s { int16_t a,b,c,d; int16_t y[]; } data = {0,0,0,0, {2,3,4,5}}; results in only the leading four int16_t values in the data segment. Either the initializer data should be emitted, or the initializer should be rejected with an error, or the struct declaration should be rejected with an error, and presumably the first option would be preferable. -- Summary: Truncated C struct data initializer with variable size trailing array Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: howard dot thomson at dial dot pipex dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36987