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