This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21668] New: gratuitous warning about "extern const" with initializer
- From: "gdr at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2005 20:10:41 -0000
- Subject: [Bug c/21668] New: gratuitous warning about "extern const" with initializer
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc spits a warning on the following snippet:
% cat const-extern.c && gcc -c const-extern.c
extern const int foo = 200;
const-extern.c:1: warning: 'foo' initialized and declared 'extern'
Notice that the code snippet is a well-defined construct at the
intersection of both C and C++, and actually is the way of
properly initializing a const object (in C++) with external
linkage -- if you remove the "extern" then, it gets an internal
linkage. So it is not helpful for the C front-end to emit
unconditional warning on that construct -- even a pedwarn
is not helpful.
-- Gaby
--
Summary: gratuitous warning about "extern const" with initializer
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gdr at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: plateform independent
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21668