http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60679
Bug ID: 60679 Summary: class specialization not instantiated even though it is a better match than the primary template Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: filip.roseen at gmail dot com Created attachment 32463 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32463&action=edit testcase.cpp template<int...> struct A { }; // (A) template<char X, char Y> struct A<X, Y> { typedef int type; }; // (B) int main () { (void) A<0, 0>::type { }; } ------------------------------------------------------------------------------- testcase.cpp: In function ‘int main()’: testcase.cpp:7:10: error: ‘type’ is not a member of ‘A<0, 0>’ (void) A<0, 0>::type { }; ^ ------------------------------------------------------------------------------- Note: `clang` correctly accepts `testcase.cpp`. ------------------------------------------------------------------------------- This is how it should look, but gcc fails on step 4); 1. first our primary template `(A)` is looked up, and our template arguments are deduced from those specified for this primary template 2. we then look for specializations, `(B)` should be found 3. `(B)` is more specialized than our primary template, proceed 4. `(B)` should be selected if no narrowing-conversion applies to instantiating it, which is true; `int { 0 }` fits inside `char` Note: A non-narrowing conversion can be proved since `0` is a constant-expression and can fit inside `char`, see [dcl.init.list]p7 5. `(B)` is the best candidate, instantiate it ------------------------------------------------------------------------------- [temp.class.spec.match]p4: > The templates arguments of a specializaton are deduced from the arguments > of the primary template. [temp.class.spec]p6 states the following: > Partial specializations declarations themselves are not found by name > lookup. Rather, when the primary template name is used, any > previously-declared partial specializations of the primary template > are also considered. -------------------------------------------------------------------------------