From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux 2.4.3 i686; en-US; 0.8.1) Gecko/20010421 Description of problem: If you have a const variable for a type with no constructors at all (i.e. only the compiler supplied default constructor), it tells you the variable is an uninitialized const. How reproducible: Always Steps to Reproduce: Given this program: ---- simpletest.cpp struct Fred { }; static const Fred fred; ---- and this command line: g++ -pipe -march=athlon -g simpletest.cpp ---- I get this erroneous error: simpletest.cpp:3: uninitialized const `fred' Actual Results: simpletest.cpp:3: uninitialized const `fred' Expected Results: /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start': /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main' collect2: ld returned 1 exit status Additional info: This is actually a heavily modified 7.0 system. But, I do have all of the gcc-2.96-81 packages, including cpp.
ISO C++ explicitely disallows this, read [dcl.init]/9: If no initializer is specified for an object ... ... if the object is of const-qualified type, the underlying class type shall have a user-defined default constructor.