Subject: Re: [boost] request for interest in a garbage collection library
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-04-23 12:04:00


Kasra wrote:

>>> auto_ptr<char*> traced_buffer(new (gc_traced) char[1024]);
>> This raises undefined behaviour, I believe.
>
> gc allocated memory slab is always zero, so there would be no
> live pointers on the traced_buffer memory slab.

C++ doesn't allow you to call delete on a pointer type you allocated
with new some_array_type, whether the type of the elements is a POD or not.
That is what raises the undefined behaviour here.

If you test your code with a type that traces construction and
destruction, you will see only the first element of the array gets
destructed, which is incorrect. Or your program might just crash.