|
Boost : |
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2007-10-02 17:47:59
Sebastian Redl wrote:
> Marco wrote:
>> Are you speaking about rules provided in the C++ ISO standard ? Could you
>> point me to them ? (page, section). I'd like to give them a look .
>>
> Reinterpret_cast is defined in 5.2.10. The language there is rather
> clear about what is guaranteed and what not. Judging by that section,
> you can't rely on the results of the cast for anything except casting it
> back.
Yes. To give a practical example: GCC will complain about invalid type casts,
since they break its ability to optimize based on proper alias analysis.
The issue is not about layout compatibility, but the compiler's
ability to infer whether two pointers may refer to the same address.
If their types differ, they may not, in general.
Regards,
Stefan
-- ...ich hab' noch einen Koffer in Berlin...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk