I have a Visual Studio 2008 C++ application for ARMV4I Windows Mobile 6 where I'm using `boost::shared_ptr<>` to manage a fairly large object (4KB). Unfortunately, `boost::make_shared<>` causes an Access Violation exception. I am using Boost 1.45.0 with STLPort 5.2.1.
My code:
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;
}
The exception 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++
The location of the exception (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! */
This issue does not occur when compiling for x86 Windows. This issue also does not occur when using the shared_ptr like this:
boost::shared_ptr< Foo > f1 = boost::shared_ptr< Foo >( new Foo );
Can anybody explain what's going on and why this is breaking only on ARMV4I Windows Mobile 6?
Thanks,
PaulH