This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11948] New: ICE on illegal code: initialising a static data member
- From: "o dot kullmann at swansea dot ac dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Aug 2003 14:48:03 -0000
- Subject: [Bug c++/11948] New: ICE on illegal code: initialising a static data member
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11948
Summary: ICE on illegal code: initialising a static data member
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: o dot kullmann at swansea dot ac dot uk
CC: gcc-bugs at gcc dot gnu dot org
#include <limits>
template <class T> struct X {
static const int max = std::numeric_limits<int>::max();
X() : m(max) {}
int m;
};
template <class T> const int X<T>::max;
int main() { X<int> x; }
compiled with g++ version 3.3.1 (without options) yields
internal compiler error: Segmentation fault
This error doesn't occur with version 3.3 or 3.2.1, since these versions
do not detect the invalid non-constant initialisation within the class.
The code
#include <limits>
template <class T> struct X {
static const int max = std::numeric_limits<int>::max();
};
template <class T> const int X<T>::max;
int main() { X<int> x; }
compiles with g++ version 3.3.1 although it is invalid.