This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11948] New: ICE on illegal code: initialising a static data member


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]