http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57433
Bug ID: 57433
Summary: Local classes have an associated namespace
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: potswa at mac dot com
The example below should fail with access to a deleted function, but is
accepted by GCC 4.9. Clang correctly rejects it.
The issue is that [basic.lookup.argdep] §3.4.2/2 is defined in terms of
namespace membership, but a local class (such as a lambda) is not a member of a
namespace.
"If T is a class type (including unions), its associated classes are: the class
itself; the class of which it is a member, if any; and its direct and indirect
base classes. Its associated namespaces are the namespaces of which its
associated classes are members."
template< typename t, typename u >
void f( t, u ) = delete;
template< typename t >
void c( t o ) { f( o, 5 ); }
namespace n {
template< typename t >
void f( t, int ) {}
void p() { c( []{} ); }
}
For the sake of argument, the same Standardese forbids the following example
because n2 is only associated with n1, not s. None of its associated classes
are members of a namespace so it is not associated. Such behavior is
ridiculous. GCC and Clang accept this… it would be surprising if any
implementation didn't.
namespace n {
struct s { struct n1 { struct n2 {}; }; };
int f( s::n1::n2 ) { return 3; }
}
int i = f( n::s::n1::n2() );