------- Additional Comments From gdr at cs dot tamu dot edu 2004-10-12 18:51 ------- Subject: Re: [3.4/4.0 regression] local classes as template argument
"mmitchel at gcc dot gnu dot org" <[EMAIL PROTECTED]> writes: [...] | Consider: | | template <typename T> | void f(T *); | | void g() { | struct S; | S* p; | f (p); // #1 | f<S> (p); // #2 | } | | If we treated deduction and explicit arguments differently, then we would put | the template in the overload set at #1 (deduction succeeds) but not at #2 | (checking of explicit arguments fails). That's odd. The difference between deduction and explicit arguments are already deep; there is no thing odd about it. They are just not the same thing and they don't work the same way. Explicit arguments in general constructs different overload sets than deduction. Furthermore, the former allows implicit conversion and the later does not. Consider template<class> struct X { } template<class T> f(T*); template<class T> f(X<T>*); void g() { struct S : X<int> { }; S* p; f(p); f<S>(p); f<int>(p); }; | John (and I) think that "instantiate" is the wrong term in the passage quoted | above, in the sense that this should not be a point-of-instantiation, I do | think, however, that the compiler must generate a declaration of the function | template, after instantiation, for use during overload resolution. That is the | natural time to issue errors about the function. Otherwise, you must queue a | possibly arbitrary error or set of errors to issue later, iff the template is | instantiated. It's not reasonable to ask that of the implementation. | | For all these reasons, I intend to fix this by issuing an error message before | overload resolution. I understand your point of view, but I don't think I agree with it. I suppose we'll have plenty time to review this point in Redmond or later. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17413