Type-punning
Andrew Pinski
pinskia@gmail.com
Tue Jun 26 21:21:00 GMT 2007
On 6/26/07, Herman Geza <hg211@hszk.bme.hu> wrote:
>
> Let me elaborate. If the compiler can detect invalid type-punning,
Not really.
> void foo(float *a) {
> int *b = (int*)a; // type-punning warning
> }
This is actually valid if we don't access both a and b and also the
original type is int.
>
> Is this reasonable?
Not really, see above. Aliasing is a hard problem to solve in
generic. So there are stuff like type based aliasing to help out the
solver. And in the case of GCC, it helps out more than other
compilers.
-- Pinski
More information about the Gcc
mailing list