Description of Problem: Try to complile this: ---cut-here---template <int SIZE> class B { public: class P { public: P(int x) : x_(x) {} int x() const { return x_; } private: int x_; }; P get_a_P() { return P(SIZE/2); } }; class G : private B<10> { public: void test(); }; template <int SIZE> B<SIZE>::P the_bug(B<SIZE>::P p) { // do nothing return p; } void G::test() { P p = get_a_P(); P q = the_bug(p); } int main() { G g; g.test(); return 0; } ---cut-here--- How Reproducible: Allways. Steps to Reproduce: 1. try to compile Actual Results: templbug.cpp: In method `void G::test ()': templbug.cpp:42: no matching function for call to `the_bug (B<10>::P &)' Expected Results: program complile Additional Information: If I do the template instantiation by hand (by replacing SIZE with 10), the code compiles.
The code is ill formed. See [templ.deduct.type]/4 and [templ.deduct.type]/14 in ISO C++. /4 sais that: The nondeduced contexts are: --The nested-name-specifier of a type that was specified using a qualified-id. /14 sais that: template<int i, typename T> T deduce(typename A<T>::X x, // T is not deduced here E.g. changing the the_bug(p) call into the_bug<10>(p) (ie. explicitely providing the template argument because it will not be deduced) should make this work.