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