From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-06-07 10:48:49
At 06:50 AM 6/7/2001, John Maddock wrote:
>> >Same things with scoped_ptr_example_test.cpp.
>> >Is this bcb5 only bug ?
>>I was able to reproduce the problem for the Borland compiler but not
>>of the others.
I've now verified that the Win32 GCC, Intel, Metrowerks, and Microsoft
compilers all handle this correctly, while Borland does not.
>It looks to be a Borland bug: for some reason the destructors of all
>sub-objects get instantiated when you write:
>Even if T has all constructors/destructor declared but not defined.
>This basically makes it impossible to implement the pimpl idon using a
>smart pointer with this compiler (or any others that have the same
>problem). Note that commenting out the static assert is *not* an option:
>the code compiles then, but issues a warning about deleting an incomplete
>type - as a result it will not behave correctly at run time - or rather
>*may* not, depending on which version or the smart_ptr's destructor makes
>it into the exe (there may be different versions in different translation
>units, some instantiated "prematurely", others not).
You were smart to figure that out. In my testing I just commented out the
assert and dumbly assumed everything was OK because the compile errors went
away. But I think that your analysis is correct, including the key point:
It isn't just the Boost smart pointer - any use of a templated pointer to
an incomplete type could fail if a translation unit with delete of an
incomplete type happens to be the one linked in.
This looks like a really disastrous bug in the Borland compiler.
I wonder if we've overlooked something? It seems like Borland users would
be howling by now if this bug is really biting people.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk