[llvm-bugs] [Bug 32985] New: typeof(const members of struct), -std=gnu89, and -Wduplicate-decl-specifier vs gcc7.1
llvm-bugs at lists.llvm.org
Tue May 9 22:48:18 PDT 2017
Bug ID: 32985
Summary: typeof(const members of struct), -std=gnu89, and
-Wduplicate-decl-specifier vs gcc7.1
Assignee: unassignedclangbugs at nondot.org
Reporter: ndesaulniers at google.com
CC: klimek at google.com, llvm-bugs at lists.llvm.org
Created attachment 18425
when I compile the attached code with the following flags, I get a warning w/
clang 4.0 & clang 3.8, but not gcc 7.1.
➜ tmp clang test_case.c -Wduplicate-decl-specifier -std=gnu89
test_case.c:10:5: warning: duplicate 'const' declaration specifier
const typeof( ((const struct x*)0)->member ) *__mptr = (z);
1 warning generated.
it seems that if I remove either `const` declarations in front of NULL point
cast within typeof(), or the `const` declaration of the member 'member', this
warning does not go away. But if I remove both `const` declarations, this goes
It seems like a bug in clang to me; we're trying to get the typeof the member,
so whatever we cast 0 to should not matter if it's const or not.
Changing the const-ness of the cast does not change the warning (expected), but
neither does changing the const-ness of member on its own (unexpected). It's
only when making both changes does this change (unexpected).
The warning also goes away when I don't use the `-std=gnu89` flag, so maybe
there's a difference in gnu89 interpretation between gcc7.1 and clang4.0?
This is making it difficult to compile the linux kernel with Clang 4.0, since
the container_of() macro used in A LOT of places uses this kind of code. My
test case was the furthest I could pair down for an example.
godbolt.org is useful in testing gcc7.1.
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-bugs