The following invalid code snippet triggers an ICE on mainline and 4.2 branch:

=====================================
template<int> struct A
{
  A(int);
};

template<int N> A<N>::A() {}

struct B
{
  A<0> a;
};

B b;
=====================================

bug.cc:6: error: prototype for 'A<N>::A()' does not match any in class 'A<N>'
bug.cc:3: error: candidate is: A<N>::A(int)
bug.cc:6: error: template definition of non-template 'A<N>::A()'
bug.cc:13: internal compiler error: in locate_ctor, at cp/method.c:899
Please submit a full bug report, [etc.]

If I replace "A(int);" by "A(0);" I get a slightly different crash:

bug.cc:3: error: expected unqualified-id before numeric constant
bug.cc:3: error: expected `)' before numeric constant
bug.cc:6: error: no 'A<N>::A()' member function declared in class 'A<N>'
bug.cc:6: error: template definition of non-template 'A<N>::A()'
bug.cc:13: internal compiler error: vector VEC(tree,base) index domain error,
in locate_ctor at cp/method.c:889
Please submit a full bug report, [etc.]


-- 
           Summary: [4.2/4.3 regression] ICE on invalid constructor
                    definition
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code, error-recovery, monitored
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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

Reply via email to