Language features and reinterpret casts

Bruno Medeiros brunodomedeiros+spam at com.gmail
Mon Nov 1 06:39:51 PDT 2010


On 21/09/2010 00:27, bearophile wrote:
> klickverbot:
>> Are there any cases where (*cast(int*)&someFloat) does not fit the bill?
>
> I am not a C lawyer, but I think that too is undefined in C (and maybe D too).
>
> Bye,
> bearophile

In general, it is definitely undefined behavior in C, but that's because 
an int in C can be bigger than a float, so you could be reading memory 
out of bounds with that. If sizeof(int) == sizeof(float), then it's 
legal in C.
Similarly, I think it is legal in D.


-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list