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

            Bug ID: 71713
           Summary: "initializer element is not constant" with nested
                    casts
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vicencb at gmail dot com
  Target Milestone: ---

Hello,

With this type definitions:
 struct Str1 { int i; };
 struct Str2 { struct Str1 *m; };

Gcc fails to compile this:
 const struct Str2 cnt = { .m = (struct Str1[]){
  (struct Str1){1}
 }};
Reporting "error: initializer element is not constant"

If the inner cast is removed:
 const struct Str2 cnt = { .m = (struct Str1[]){
  {1}
 }};
Then it works fine.

As a side note, clang accepts it.

Thanks,
  Vicente.

Reply via email to