A recent build of GCC 4.8 gives the following code, when in a header file:
auto L = [](){};
struct S
{
decltype(L) m;
};
the following warning:
test.hpp:3:8: warning: 'S' has a field 'S::m' whose type uses the anonymous namespace [enabled by default]
struct S
^
Why does the compiler consider the type of the lambda to use the anonymous namespace? I made the lambda global, I didn't use an anonymous namespace anywhere.
UPDATE: The compiles gives the same warning even if I put the lambda in an explicit namespace, like so:
namespace N
{
auto L = [](){};
}
struct S
{
decltype(N::L) m;
};
UPDATE 2: In fact, it seems even class scope lambdas have the same problem:
class N
{
static constexpr auto L = [](){};
};
struct S
{
decltype(N::L) m;
};