This is the mail archive of the gcc-bugs@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]

[Bug c/64856] New: Initializing struct not accepted in gnu99


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

            Bug ID: 64856
           Summary: Initializing struct not accepted in gnu99
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org

struct A {
  unsigned long b;
};

struct B {
  struct A c[2];
};

struct B d = { .c = { [0 ... 1] = (struct A){ .b = -1UL } } };

$ ./cc1 -quiet j.c -std=gnu90
$ ./cc1 -quiet j.c -std=gnu99
j.c:9:35: error: initializer element is not constant
 struct B d = { .c = { [0 ... 1] = (struct A){ .b = -1UL } } };
                                   ^
j.c:9:35: note: (near initialization for âd.c[0]â)
j.c:9:35: error: initializer element is not constant
j.c:9:35: note: (near initialization for âd.c[1]â)

This is bad with gnu11 as a default.

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