[LLVMbugs] [Bug 12884] New: crash-on-invalid with explicit specialization of member of class template

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 18 16:40:31 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12884

             Bug #: 12884
           Summary: crash-on-invalid with explicit specialization of
                    member of class template
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu,
                    rikka at google.com
    Classification: Unclassified


This code:

template<typename T> struct A {
  struct B {
    template<typename U> struct X {};
    typedef int arg;
  };
  struct C {
    typedef B::X<typename B::arg> x;
  };
};

template<>
struct A<int>::B {
  template<int N> struct X {};
  static const int arg = 0;
};

A<int>::C::x a;

crashes Clang with:

Unable to find instantiation of declaration!
UNREACHABLE executed at lib/Sema/SemaTemplateInstantiateDecl.cpp:3412!

The distal cause of the crash appears to be that we accept:

    typedef B::X<typename B::arg> x;

Here, the name B::X does not refer to a member of the current instantiation,
but we are treating it as if it did (the same issue occurs if the typedef 'x'
appears directly within A, rather than nested inside 'struct C'). This code is
therefore ill-formed, and must be written as:

    typedef typename B::template X<typename B::arg> x;

... at which point the crash goes away. Indeed, we can then write:

    typedef typename B::template X<B::arg> x;

... and the program is accepted.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list