Avoiding "assignment from incompatible pointer type" warning

Florian Weimer fw@deneb.enyo.de
Mon Oct 21 03:12:00 GMT 2002


"Joshua Nye" <josh@boxcarmedia.com> writes:

>> > int *p;
>> > float g = 3.141592653589793238;
>> > p = (int *)&g;
>> 
>> Is this code legal?  I doubt it.
>> 
>
> What do you consider legal and why wouldn't it be?

Casting a pointer from float to int can result in undefined behavior
on some implementations.



More information about the Gcc-help mailing list