When the struct/class is outside the function:
#include <vector>
struct Foo { };
int main()
{
std::vector< Foo > foos;
return 0;
}
Visual Studio 2012's STL debug visualizer handles foos
just fine:
Name Value Type
- foos { size=0 } std::vector<Foo,std::allocator<Foo> >
[size] 0 int
[capacity] 0 int
+ [Raw View] 0x0026fbcc {...} std::vector<Foo,std::allocator<Foo> > *
But when Foo
is inside main()
:
#include <vector>
int main()
{
struct Foo { };
std::vector< Foo > foos;
return 0;
}
The debugger spits back garbage(?) types/values that look like name mangling gone horribly wrong:
Name Value Type
- foos {...} std::?$vector@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@
- std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@ {...} std::?$_Vector_alloc@$0A@U?$_Vec_base_types@UFoo@?1?main@V?$allocator@UFoo@?1?main@@std@@@std@@
- std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@ {_Myfirst=0x00000000 {...} _Mylast=0x00000000 {...} _Myend=0x00000000 {...} } std::?$_Vector_val@U?$_Simple_types@UFoo@?1?main@@std@@
std::_Container_base0 {...} std::_Container_base0
_Myfirst 0x00000000 {...} main::__l2::Foo *
_Mylast 0x00000000 {...} main::__l2::Foo *
_Myend 0x00000000 {...} main::__l2::Foo *
Two questions:
- What's going on here?
- Any fixes/workarounds? (...other than the obvious "move
Foo
outsidemain()
")