Pau*_*ulH 5 c++ boost windows-mobile
我有一个用于ARMV4I Windows Mobile 6的Visual Studio 2008 C++应用程序,我用它boost::shared_ptr<>来管理一个相当大的对象(4KB).不幸的是,boost::make_shared<>导致访问冲突异常.
我的代码:
struct Foo
{
char a[ 4 * 1024 - 1 ];
};
int _tmain( int argc, _TCHAR* argv[] )
{
boost::shared_ptr< Foo > f = boost::make_shared< Foo >(); // Access Violation
return 0;
}
Run Code Online (Sandbox Code Playgroud)
callstack异常:
test.exe!boost::detail::sp_ms_deleter<o>::sp_ms_deleter<o>(void) Line: 60, Byte Offsets: 0x18 C++
test.exe!boost::make_shared<o>(void) Line: 106, Byte Offsets: 0x5c C++
test.exe!wmain(int argc = 1, wchar_t** argv = 0x01b40060) Line: 81, Byte Offsets: 0x18 C++
test.exe!mainWCRTStartup(HINSTANCE__* hInstance = 0x00000003, HINSTANCE__* hInstancePrev = 0x00000000, unsigned short* lpszCmdLine = 0x00000003, int nCmdShow = 0) Line: 188, Byte Offsets: 0x94 C++
Run Code Online (Sandbox Code Playgroud)
异常的位置(boost\smart_ptr\make_shared.hpp):
template< class T > class sp_ms_deleter
{
/* snip! */
public:
sp_ms_deleter(): initialized_( false )
{ // line: 60 this = NULL
}
/* snip! */
Run Code Online (Sandbox Code Playgroud)
编译x86 Windows时不会发生此问题.使用shared_ptr时也不会发生此问题:
boost::shared_ptr< Foo > f1 = boost::shared_ptr< Foo >( new Foo );
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释发生了什么以及为什么这只会破坏ARMV4I Windows Mobile 6?
谢谢,PaulH