[Bug c/80868] New: "Duplicate const" warning emitted in `const typeof(foo) bar;`
george.burgess.iv at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 23 20:23:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80868
Bug ID: 80868
Summary: "Duplicate const" warning emitted in `const
typeof(foo) bar;`
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: george.burgess.iv at gmail dot com
Target Milestone: ---
Minimal test-case (repros with 7.1: https://godbolt.org/g/A2dTCP):
$ cat tc.c
const int i;
const typeof(i) j;
$ gcc -std=gnu89 -pedantic tc.c
2:17: warning: duplicate 'const' [-Wpedantic]
const typeof(i) j;
Expected behavior: no duplicate const warning when there's only one `const` on
the decl for `j`.
While the current behavior is understandable, I think it would be good to relax
the warning in this case. typeof is often used in macros, so silencing this
warning isn't always trivial. Since typeof is also a language extension, I
don't believe that C89 6.5.3 (which I assume is the only reason GCC is emitting
these complaints in the first place) needs to apply here.
Thank you for your time :)
More information about the Gcc-bugs
mailing list