"The character cannot be defined inside" unrelated_namespace "" - lambda nested in lambda-pass-as-argument

The following code will compile with FIXME installed, but not without it. The corresponding compiler is visual studio 2013.

#include <functional>

#ifdef FIXME
namespace unrelated_namespace {
    struct ned {};
}
#endif

namespace something {
    struct do_something {
        template <typename T>
        do_something(T f) {}
    };
}

using namespace something;

do_something my_something([](){
    std::function<void(void)> inner([]{});
});

#ifndef FIXME
namespace unrelated_namespace {
    struct ned {};
}
#endif

      

The errors are as follows:

Error   2   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::()::<lambda_cac50c1ea5c52e062ca61c564ead686c>' :
  symbol cannot be defined within namespace 'unrelated_namespace'
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

Error   3   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::<helper_func_cdecl>::<lambda_8c92b136dc3e83c8e0db25c06e4203d5>' : 
  symbol cannot be defined within namespace 'unrelated_namespace'   
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

Error   3   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::<helper_func_cdecl>::<lambda_8c92b136dc3e83c8e0db25c06e4203d5>' :
  symbol cannot be defined within namespace 'unrelated_namespace'   
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

      

g ++ uses code without complaint (e.g. http://ideone.com/ZEPYE7 ).

Is there any explanation for this behavior other than a compiler error?

+3


source to share





All Articles