Language features and reinterpret casts

Don nospam at nospam.com
Tue Sep 21 00:24:41 PDT 2010


BCS wrote:
> Hello Don,
> 
>> BCS wrote:
>>
>>> Hello bearophile,
>>>
>>>> Jesse Phillips:
>>>>
>>>>> Why not, define the behavior and leave it.
>>>>>
>>>> This was the original purpose of my thread, but Walter has explained
>>>> me that this is not possible for the unions:
>>>>
>>> I don't see how those apply to unions.
>>>
>> It's going to be implementation defined behaviour (will depend on
>> endianness)
> 
> Does that matter if the members are the same size?

Definitely -- you'll grab the part of the mantissa, instead of the exponent.
It should however only be hardware-and-OS-dependent, rather than 
compiler-dependent.
(It can be OS-dependent because of different padding rules).

> 
>> but not undefined behaviour.
>> BTW std.math heavily relies on reinterpret casting float->int.


More information about the Digitalmars-d mailing list