Bug 39188 - gcc improperly errors on const declaration
Summary: gcc improperly errors on const declaration
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-05-05 05:35 UTC by Omnifarious
Modified: 2007-04-18 16:33 UTC (History)
0 users

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


Attachments (Terms of Use)

Description Omnifarious 2001-05-05 05:35:57 UTC
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.

Comment 1 Jakub Jelinek 2001-05-05 16:51:05 UTC
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.