Bug 13157 - [3.3 Regression] Argument Dependent Lookup Failure
Summary: [3.3 Regression] Argument Dependent Lookup Failure
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 13553 (view as bug list)
Depends on:
Blocks: 12944
  Show dependency treegraph
 
Reported: 2003-11-22 00:54 UTC by Dave Abrahams
Modified: 2004-10-30 21:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3 3.4.0 4.0.0
Known to fail:
Last reconfirmed: 2003-11-24 14:29:45


Attachments
zipped preprocessed source (142.29 KB, application/octet-stream)
2003-11-22 00:55 UTC, Dave Abrahams
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Abrahams 2003-11-22 00:54:19 UTC
The attached should compile, but fails.
Comment 1 Dave Abrahams 2003-11-22 00:55:03 UTC
Created attachment 5187 [details]
zipped preprocessed source
Comment 2 Andrew Pinski 2003-11-22 01:28:44 UTC
Most likely fixed for 3.4 but I have not checked.
Comment 3 Andrew Pinski 2003-11-22 01:54:45 UTC
Actually the code should not be able to compile:
The following lines cause this (and the others like them):
            using ::std::abs;
            using ::std::sinh;
            using ::std::sqrt;

In boost::math::sinhc_pi and others.
Comment 4 Dave Abrahams 2003-11-22 03:42:03 UTC
Wrong again.  Unqualified calls are subject to argument dependent lookup 
regardless of what names are brought in via using declarations.  The reduced 
case is:

#include <cmath>

namespace fu
{
   template <class T>
   struct X
   {};

  template <class T>
  X<T> test(X<T> x)
  {
       using ::std::abs;
       return abs(x);
  }
  
   template <class T>
   X<T> abs(X<T>);

   X<int> x;
   X<int> z = test(x);
}
Comment 5 Wolfgang Bangerth 2003-11-24 14:29:45 UTC
Yes, this should compile.
Comment 6 Andrew Pinski 2004-01-03 11:54:06 UTC
*** Bug 13553 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2004-01-03 12:00:14 UTC
Here is an example without using the namespace std (as that is a special namespace for 2.95.3):
namespace aa
{
  double abs(double);
  long double abs(long double);
}

namespace fu
{
   template <class T>
   struct X
   {};

  template <class T>
  X<T> test(X<T> x)
  {
       using ::aa::abs;
       return abs(x);
  }
  
   template <class T>
   X<T> abs(X<T>);

   X<int> x;
   X<int> z = test(x);
}

From Phil's regression hunter: Search converges between 2001-02-25-trunk (#8) and 2001-03
-04-trunk (#9).
Comment 8 CVS Commits 2004-01-05 06:24:56 UTC
Subject: Bug 13157

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-01-05 06:24:47

Modified files:
	gcc/cp         : ChangeLog name-lookup.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: koenig3.C 

Log message:
	PR c++/13157
	* name-lookup.c (lookup_using_namespace): Remove spacesp
	parameter.
	(unqualified_namespace_lookup): Likewise.
	(lookup_qualified_name): Adjust accordingly.
	(lookup_name_real): Likewise.
	(lookup_arg_dependent): Do not eliminate the namespace of the
	functions found by unqualified name lookup unless that is the
	current namespace.
	
	PR c++/13157
	* g++.dg/template/koenig3.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3853&r2=1.3854
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.30&r2=1.31
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3334&r2=1.3335
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/koenig3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 Mark Mitchell 2004-01-05 06:26:25 UTC
Fixed in GCC 3.4.
Comment 10 Gabriel Dos Reis 2004-02-15 12:37:33 UTC
Adjust milestone
Comment 11 Gabriel Dos Reis 2004-04-27 06:30:20 UTC
This has been fixed in 3.4.0 and 3.5.0.
During the parser rewriting, many functions saw the light but there are little
or no corresponding entries in the ChangeLog (contrary to our conventions),
so it is a bit hard to have a 
backport that is close to 3.4.0 codes.
Won't fix in 3.3.x.