[Bug c++/86577] New: non-ADL name lookup for operator<< at instantiation time?
zhonghao at pku dot org.cn
gcc-bugzilla@gcc.gnu.org
Wed Jul 18 23:58:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86577
Bug ID: 86577
Summary: non-ADL name lookup for operator<< at instantiation
time?
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhonghao at pku dot org.cn
Target Milestone: ---
The code is as follow:
#include <iostream>
namespace N {
struct X { };
}
using namespace N;
template<typename T>
void log(const T& t) {
std::clog << t;
}
std::ostream &operator<<(std::ostream&, const X& x);
template void log(const X&);
g++ accepts the code, but clang++ rejects it:
code0.cpp:10:12: error: call to function 'operator<<' that is neither visible
in the template definition nor found by argument-dependent lookup
std::clog << t;
^
code0.cpp:15:16: note: in instantiation of function template specialization
'log<N::X>' requested here
template void log(const X&);
^
code0.cpp:13:16: note: 'operator<<' should be declared prior to the call site
or in namespace 'N'
std::ostream &operator<<(std::ostream&, const X& x);
^
1 error generated.
Does g++ perform non-ADL name lookup for operator<< at instantiation time? This
sounds incorrect.
More information about the Gcc-bugs
mailing list