c/7963: gnu99 doesn't allow compound literals for static initializers

mrs@apple.com mrs@apple.com
Tue Sep 17 23:16:00 GMT 2002


>Number:         7963
>Category:       c
>Synopsis:       gnu99 doesn't allow compound literals for static initializers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 17 22:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     mrs@apple.com
>Release:        gcc version 3.1 20020420
>Organization:
>Environment:

>Description:
GNU gnu99 is missing a feature, compound literals for static initializers should be accepted in gnu99 mode, as they are in gnu89 mode.

http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html#Compound%20Literals
typedef struct A { int i; } At;

void foo() {
  static At a = (At){0};
  static int y[] = (int []) {1, 2, 3};
}

bash-2.05a$ gcc -c -xc t3.m -std=gnu99
t3.m: In function `foo':
t3.m:4: initializer element is not constant
t3.m:5: array initialized from non-constant array expression

See also Radar 3033979.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list