|
Boost Interest : |
Subject: Re: [Boost-cmake] placement_new test failure under VC++8
From: Mike Jackson (mike.jackson_at_[hidden])
Date: 2009-05-17 18:08:16
On Sat, May 16, 2009 at 7:25 PM, David Wolfe <dwolfe_at_[hidden]> wrote:
>> Debug Error!
>> File
>> c:\projects\boost\libs\numeric\ublas\placement_new.cpp
>> Line: 63
>>
>> Run-Time Check Failure #2 - Stack around the variable 'a' was
>> corrupted.
>
>
> On 5/16/2009 7:59 AM, Mike Jackson wrote:
>>
>> So I am going to assume that there is an actual bug in the code. Is it
>> possible to debug the program with a debugger and get the line of code
>> that VS is bombing on?
>
> It's definitely the creation of the 1-element UDT array at the same
> address as the scalar instance that's causing the runtime check to
> trigger:
>
> udt a;
> udt* ap = &a;
>
> // Capture placement new offsets for a udt
> new (ap) udt;
> int new_offset = int (udt::base_pointer - ap);
> new (ap) udt [1];
> int array_new_offset = int (udt::base_pointer - ap);
>
>
> If I comment out the line that reads 'new (ap) udt[1]', the assertion
> doesn't trigger.
I don't know the udt api but if you really are creating a 1 element
array then trying to access element at index=1 is an error. Trying to
access element at index=0 would be valid. So commenting out the line
obviously gets rid of the error.
I don't know what the intent of the test is but if you replace the [1]
with [0] and try does it succeed?
Try contacting the author of the test/code or ask on the normal boost
mailing list.
Mike Jackson