New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 11421 - Crash instantiating member template
Summary: Crash instantiating member template
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 07:52 PST by Marc Glisse
Modified: 2012-04-25 13:42 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2011-11-22 07:52:16 PST
template < unsigned > struct Combinatorial_map_base {
        static const unsigned dimension = 3;
        template<unsigned dim=dimension> struct One_dart_per_incident_cell_range: XXXXXXXXXdart_per_incident_cell_name<dim> {
        };
};
typedef Combinatorial_map_base<3> LCC_3;
LCC_3::One_dart_per_incident_cell_range<>::iterator          it;

$ clang++ -fsyntax-only a.ii
segfaults. It doesn't if I change the name starting with XXX.

(produced by delta, I still don't think that's the bug I am after...)
Comment 1 Tyler Breisacher 2012-02-18 21:43:50 PST
It looks like when you type the XXX name, clang thinks you just mistyped "One_dart_per_incident_cell_range" and it carries on valiantly as though you had typed "One_dart_per_incident_cell_range". So, here's a slightly smaller test case:

template<unsigned> struct B {
  static const unsigned dimension = 3;
  template<unsigned dim=dimension> struct A : A<dim> {};
};
B<0>::A<>::iterator it;

It still segfaults when you try to compile that. I'm very new to clang, but I managed to trace the problem to here: http://clang.llvm.org/doxygen/SemaDeclCXX_8cpp_source.html#l08409

Base->getType()->getAs<RecordType>() is returning null, so when you call getDecl() on it, bad things happen. Hope this helps. =)
Comment 2 Douglas Gregor 2012-03-10 20:44:03 PST
This doesn't actually involve typo correction. This slightly-reduced example fails in the same way:

template < unsigned > struct X {
  static const unsigned dimension = 3;
  template<unsigned dim=dimension> 
  struct Y: Y<dim> { };
};
typedef X<3> X3;
X3::Y<>::iterator it;
Comment 3 Argyrios Kyrtzidis 2012-04-25 13:42:36 PDT
Fixed in r155576.