|
Boost : |
From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-11-02 19:56:51
Peter Dimov wrote:
> (A reinterpret_cast<char*>( p ) is indirectly required to work when p is a
> pointer to a class type, but it's possible in theory for a sufficiently
> mischievous compiler to break it for long*. I know of no such compiler,
> present or future, of course.)
Is reinterpret_cast<char*>( pointer-to-a-class-type ) the only case when
reinterpret_cast is required to work?
Is it required to work in this case: array of a scalar-type to a
pointer-to-scalar-type ?
extern char cpp_signature_tag[];
...
reinterpret_cast<const char*>(detail::cpp_signature_tag)
Just trying to understand when it is safe to use reinterpret_cast.
Thanks,
Boris
----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, November 02, 2007 7:03 PM
Subject: Re: [boost] [serialization] patch for portable_binary_oarchive.hpp
> Boris Gubenko:
>
>>> I think the correct change to silence the type conversion error is
>>>
>>> char * first = static_cast<char *>(static_cast<void
>>> *>(const_cast<long*>(&
>>> l)));
>>
>> I'm not sure my change is incorrect. In terms of style, I think that your
>> change is better.
>
> Dave's insistence that we have to obfuscate our reinterpret_casts is well
> known and a very strict reading of the standard is on his side _in this
> specific case_, but I personally don't find his style better at all.
>
> (A reinterpret_cast<char*>( p ) is indirectly required to work when p is a
> pointer to a class type, but it's possible in theory for a sufficiently
> mischievous compiler to break it for long*. I know of no such compiler,
> present or future, of course.)
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk