Bug 39188 - gcc improperly errors on const declaration
gcc improperly errors on const declaration
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2001-05-05 01:35 EDT by Omnifarious
Modified: 2007-04-18 12:33 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-05-05 01:36:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Omnifarious 2001-05-05 01:35:57 EDT
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:

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':
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.
Comment 1 Jakub Jelinek 2001-05-05 12:51:05 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.