This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30962] New: cause compile error for "const anonymous class object"
- From: "gzljg at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Feb 2007 18:36:03 -0000
- Subject: [Bug c++/30962] New: cause compile error for "const anonymous class object"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
First I cannot find the exact C++ definition of "const anonymous object" so I
am not sure the below reporting is valid or not. The question to me is: why
adding 'const' to the class declaration will invalidate the code while without
'const' is ok?
The following code will compile and run without error, but if add back the
"const" declaration before 'class', it will report an error of "
Error: uninitialized const `MyAnonymous'"
This had been tested with gcc 3.3.3 & 4.1.2.
/* const */ class
{
public:
int foo() const
{
return 1;
}
} MyAnonymous;
int
main()
{
return MyAnonymous.foo();
}
--
Summary: cause compile error for "const anonymous class object"
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gzljg at hotmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30962