This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 3.4 Bug? template dependent name lookup fails from template functions


Michael Veksler <VEKSLER@il.ibm.com> writes:

| I worte:
| MV>    template <class T> struct A {};
| MV> 
| MV>    template <class T>
| MV>    void F(const A<T> & )
| MV>    {
| MV>        T t;
| MV>        F(t); // ok for T=double
| MV>        ::F(t); // fails for T=double, does not find F(double)
| MV>    }
| MV>    void F(double) { } // This will be found, if moved before F<T>
| MV> 
| MV>    int main()
| MV>    {
| MV>        A<double> a;
| MV>        F(a); //[....]
| MV>    }
| 
| llewelly@xmission.com writes:
| 
| LL>However - this can't be the end of it; comeau online reports errors
| LL>     for *both* calls to F, unlike gcc 3.4 which at least accepts the
| LL>     first call.
| 
| Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
| 
| GDR> como is right and GCC is wrong.  The reason is that in the call F(t),
| GDR> F is dependent, so it is resolved at instantiation time through
| GDR> argument dependent name lookup.  However, because double is
| GDR> a builtin type, the set its associated namespaces and classes is
| GDR> empty.  Therefore, the call fails for "no matching" function.
| GDR> This is just one of the few cases where we do not do ADL right.
| GDR> Another case I'm aware of is when we should be ignoring functions
| GDR> with internal linkage, in the second phase of name lookup.
| 
| You can define class B then search and replace double with B.
| You will get more of the same with GCC-3.4.

*If* you use a class, *then* GCC behaviour is right.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]