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 libstdc++/80504] New: missing qualification causes ADL to be used in std::ref / std::cref


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80504

            Bug ID: 80504
           Summary: missing qualification causes ADL to be used in
                    std::ref / std::cref
           Product: gcc
           Version: 5.4.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

This valid code is rejected:

#include <functional>

namespace X {
  struct Y { };
  template<typename T> void ref(T) { }
  template<typename T> void cref(T) { }
}

int main()
{
  X::Y i;
  std::reference_wrapper<X::Y> r(i);
  ref(r);
  cref(r);
}


In file included from r.cc:1:0:
/usr/include/c++/6.3.1/functional: In instantiation of
‘std::reference_wrapper<_Tp> std::ref(std::reference_wrapper<_Tp>) [with _Tp =
X::Y]’:
r.cc:13:8:   required from here
/usr/include/c++/6.3.1/functional:492:17: error: call of overloaded
‘ref(X::Y&)’ is ambiguous
     { return ref(__t.get()); }
              ~~~^~~~~~~~~~~
/usr/include/c++/6.3.1/functional:473:5: note: candidate:
std::reference_wrapper<_Tp> std::ref(_Tp&) [with _Tp = X::Y]
     ref(_Tp& __t) noexcept
     ^~~
r.cc:5:29: note: candidate: void X::ref(T) [with T = X::Y]
   template<typename T> void ref(T) { }
                             ^~~
In file included from r.cc:1:0:
/usr/include/c++/6.3.1/functional: In instantiation of
‘std::reference_wrapper<const _Tp> std::cref(std::reference_wrapper<_Tp>) [with
_Tp = X::Y]’:
r.cc:14:9:   required from here
/usr/include/c++/6.3.1/functional:498:18: error: call of overloaded
‘cref(X::Y&)’ is ambiguous
     { return cref(__t.get()); }
              ~~~~^~~~~~~~~~~
/usr/include/c++/6.3.1/functional:479:5: note: candidate:
std::reference_wrapper<const _Tp> std::cref(const _Tp&) [with _Tp = X::Y]
     cref(const _Tp& __t) noexcept
     ^~~~
r.cc:6:29: note: candidate: void X::cref(T) [with T = X::Y]
   template<typename T> void cref(T) { }
                             ^~~~

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