This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/8032: GCC >= 3.0 incorrectly initializes static structs in the presence of flexible arrays


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]