This is the mail archive of the gcc-bugs@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]

[Bug c++/11940] New: Ambiguous name lookup error regression


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11940

           Summary: Ambiguous name lookup error regression
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: raimond_merkert at raytheon dot com
                CC: gcc-bugs at gcc dot gnu dot org

The following code no longer compiles with GCC 3.4 (gcc-3.4-20030813):

cat >> test.cpp <<EOF
#include <vector>

namespace n {
  template <class T>
   inline void swap (T& x, T& y)
   { T t(x);x=y;y=x; }

   struct Y {};

   void foo()
   {
      ::std::vector<Y> v1;
      ::std::vector<Y> v2;
      v1.swap(v2);
   }
}
EOF
g++ test.cpp -c
This is the error message I'm getting:
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_vector.h:
In
   member function `void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp,
   _Alloc>&) [with _Tp = n::Y, _Alloc = std::allocator<n::Y>]':
test.cpp:14:   instantiated from here
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_vector.h:730:
error: call
   of overloaded `swap(n::Y*&, n::Y*&)' is ambiguous
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_algobase.h:119:
note: candidates
   are: void std::swap(_Tp&, _Tp&) [with _Tp = n::Y*]
test.cpp:6: note:                 void n::swap(T&, T&) [with T = n::Y*]
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_vector.h:731:
error: call
   of overloaded `swap(n::Y*&, n::Y*&)' is ambiguous
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_algobase.h:119:
note: candidates
   are: void std::swap(_Tp&, _Tp&) [with _Tp = n::Y*]
test.cpp:6: note:                 void n::swap(T&, T&) [with T = n::Y*]
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_vector.h:732:
error: call
   of overloaded `swap(n::Y*&, n::Y*&)' is ambiguous
/local/gcc-3.4-20030813/lib/gcc/i686-pc-linux-gnu/3.4/../../../../include/c++/3.4/bits/stl_algobase.h:119:
note: candidates
   are: void std::swap(_Tp&, _Tp&) [with _Tp = n::Y*]
test.cpp:6: note:                 void n::swap(T&, T&) [with T = n::Y*]

I'm fairly sure that the code is correct, because the offending line in
stl_vector actually calls std::swap() and not just swap. 
Is this an incorrect application of Koenig lookup?

Code compiles fine with 3.3.1


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