c++ - Nested namespaces and ambiguous symbol -
i have problem involes nested namespaces , templated classes. able create test case produces same error actual code, bit more readable.
compiling following code using vs2012 2010 platform toolset causes error:
namespace { namespace b { namespace c1 { struct smeasresult{}; } namespace c2 { struct smeasresult{}; } } } namespace c1test { using namespace a::b::c1; template<typename t> class fook { public: void yu() { smeasresult field; } }; } namespace c2test { using namespace a::b::c2; template<typename t> class fook { public: void yu() { smeasresult field; } }; } void m(){ c1test::fook<int> yu; c2test::fook<int> me; yu.yu(); me.yu(); } the specific error follows:
1>------ build started: project: multivicomtest (visual studio 2010), configuration: debug win32 ------ 1> test.cpp 1>c:\code\test.cpp(27): warning c4101: 'field' : unreferenced local variable 1> c:\code\test.cpp(26) : while compiling class template member function 'void c1test::fook<t>::yu(void)' 1> 1> [ 1> t=int 1> ] 1> c:\code\test.cpp(49) : see reference class template instantiation 'c1test::fook<t>' being compiled 1> 1> [ 1> t=int 1> ] 1>c:\code\test.cpp(43): error c2872: 'smeasresult' : ambiguous symbol 1> 'c:\code\test.cpp(11) : a::b::c2::smeasresult' 1> or 'c:\code\test.cpp(7) : a::b::c1::smeasresult' 1> c:\code\test.cpp(42) : while compiling class template member function 'void c2test::fook<t>::yu(void)' 1> 1> [ 1> t=int 1> ] 1> c:\code\test.cpp(50) : see reference class template instantiation 'c2test::fook<t>' being compiled 1> 1> [ 1> t=int 1> ] ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== i not understand why symbol 'smeasresult' ambigous compiler, used in separate namespace. find out far, problem appears when classes templated classes. same problem not appear when template definition removed.
can tell me if did wrong?
this looks compiler bug me. when consider c1test version of function compiled without ambiguity, suspect somehow using namespace within namespace c1test lingering on c2test namespace.
this further corroborated fact g++ 4.4 , 4.5 can both compile code fine.
Comments
Post a Comment