[Bug c++/11497] New: const instance of class requires ctor definition
frank6thursday at aol dot com
gcc-bugzilla@gcc.gnu.org
Fri Jul 11 02:52:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11497
Summary: const instance of class requires ctor definition
Product: gcc
Version: 3.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: frank6thursday at aol dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: GNU C++ version 3.2.1 (i686-pc-linux-gnu)
GCC host triplet: GNU C++ version 3.2.1 (i686-pc-linux-gnu)
GCC target triplet: GNU C++ version 3.2.1 (i686-pc-linux-gnu)
A const instance of a class requires that the class has a constructor defined.
The default constructor is not accepted. The following code will not compile:
test.cpp
--------
struct A{};
int main(){
const A a;
}
The following error is generated:
test.cpp: In function `int main()':
test.cpp:7: uninitialized const `a'
However the following code will compile:
test.cpp
--------
struct A
{
A(){}
};
int main(){
const A a;
}
This also did not work using GNU C++ version 2.96 20000731 (Red Hat Linux 7.1
2.96-98)
Perhaps this is related to issue #5650?
More information about the Gcc-bugs
mailing list