[Bug c++/33093] New: ICE in C++ frontend with constant defined in template specialization

ian at airs dot com gcc-bugzilla@gcc.gnu.org
Thu Aug 16 20:49:00 GMT 2007


When I compile this test case with gcc 4.1, 4.2, or mainline, I get an ICE:

foo.cc: In instantiation of ‘const unsigned char B<unsigned char>::c’:
foo.cc:20:   instantiated from ‘const unsigned char C<A<unsigned char> >::c’
foo.cc:26:   instantiated from here
foo.cc:20: internal compiler error: in instantiate_decl, at cp/pt.c:14162

As far as I can see this is valid C++ code.

template<typename T> class A
{
public:
  typedef T T1;
};

template<typename T> class B
{
public:
  static const T c;
};

template<unsigned char>
const unsigned char B<unsigned char>::c = 1;

template<typename T> class C
{
public:
  typedef typename T::T1 T2;
  static const T2 c = B<T2>::c;
};

unsigned char
fn ()
{
  return C<A<unsigned char> >::c;
}


-- 
           Summary: ICE in C++ frontend with constant defined in template
                    specialization
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33093



More information about the Gcc-bugs mailing list