[llvm-bugs] [Bug 42223] New: transferring the warning on designated_init on a non-struct to an error?

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 10 23:05:50 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42223

            Bug ID: 42223
           Summary: transferring the warning on designated_init on a
                    non-struct to an error?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

My clang is 9.0.0, and the code is:

struct S {
 int a;
 union {
 int b;
 int c;
 };
} __attribute__((designated_init));

static struct S s = {
 .a = 0,
 .b = 0,
};

union U {
 int a;
 struct {
 int b;
 int c;
 } __attribute__((designated_init));
};

static union U u = {
 .b = 0,
 .c = 0,
};

clang produces the warnings:

<source>:7:18: warning: unknown attribute 'designated_init' ignored
[-Wunknown-attributes]

} __attribute__((designated_init));

                 ^

<source>:19:19: warning: unknown attribute 'designated_init' ignored
[-Wunknown-attributes]

 } __attribute__((designated_init));

                  ^

2 warnings generated.

Compiler returned: 0

Meanwhile, gcc rejects it:

<source>:25:1: error: too many initializers for 'U'

   25 | };

      | ^

Compiler returned: 1

The code comes from a gcc bug reprt:

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

Some discussions seem to be useful.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190611/821a9254/attachment.html>


More information about the llvm-bugs mailing list