[Bug c++/57874] New: No SFINAE on ADL lookup failure
gpderetta at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 10 16:27:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57874
Bug ID: 57874
Summary: No SFINAE on ADL lookup failure
Product: gcc
Version: 4.7.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gpderetta at gmail dot com
It seems that at least GCC 4.7 fails with an hard error on failure to lookup a
function via ADL in a sfinae context, if a function of that name is not visible
in scope. The following test fails to compile unless WORKAROUND is defined:
#ifdef WORKAROUND
struct unusable{};
void foo(unusable);
#endif
namespace NX
{
struct X {};
void foo(X){}
}
namespace NY
{
struct Y {};
}
template<class T>
auto ADLfoo(T&&x) -> decltype((foo(T{}), short())); //decltype(foo(x));
char ADLfoo(...);
static_assert(sizeof(ADLfoo(NY::Y{})) == 1, "");
static_assert(sizeof(ADLfoo(NX::X{})) == 2, "");
int main(){}
# g++ --std=c++11 -C adl.cc
adl.cc: In substitution of ‘template<class T> decltype ((foo(T{}), short
int())) ADLfoo(T&&) [with T = NY::Y]’:
adl.cc:24:36: required from here
adl.cc:19:6: error: ‘foo’ was not declared in this scope
adl.cc:19:6: note: suggested alternative:
adl.cc:9:6: note: ‘NX::foo’
Clang 3.2 compiles this fine.
More information about the Gcc-bugs
mailing list