public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/8032: GCC >= 3.0 incorrectly initializes static structs in the presence of flexible arrays
@ 2002-09-25  3:56 wolfgang.thaller
  0 siblings, 0 replies; only message in thread
From: wolfgang.thaller @ 2002-09-25  3:56 UTC (permalink / raw)
  To: gcc-gnats; +Cc: wolfgang.thaller


>Number:         8032
>Category:       c
>Synopsis:       GCC >= 3.0 incorrectly initializes static structs in the presence of flexible arrays
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 25 03:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Thaller
>Release:        3.0.2 and Apple-GCC version 1161, based on gcc version 3.1 20020420
>Organization:
>Environment:
Observed on MacOS X 10.2 with Apple's GCC 3.1, and with GCC 3.0.2 cross-compiling to AVR
>Description:
GCC incorrectly initializes a global struct if its initializer contains an initializer for a zero-length array. The struct is set to all-zeroes instead of the proper values for the other fields.
>How-To-Repeat:
// compile this and look at the assembly:
typedef struct x_
{
    int a;
    int b;
    int z[0]
} X;

const X xxx = { b: 40, z:{} };
>Fix:
Omit the (useless) initializer z:{} or give the array z a non-zero size.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-25 10:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25  3:56 c/8032: GCC >= 3.0 incorrectly initializes static structs in the presence of flexible arrays wolfgang.thaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).