This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 3.4 Bug? template dependent name lookup fails from template functions
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Michael Veksler <VEKSLER at il dot ibm dot com dot integrable-solutions dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: 15 Apr 2004 21:02:40 +0200
- Subject: Re: 3.4 Bug? template dependent name lookup fails from template functions
- Organization: Integrable Solutions
- References: <OF071E631E.00687482-ONC2256E77.0057F4B0-C2256E77.0058EEA8@il.ibm.com>
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