Calling a function with a float argument modifies caller's state.
Andrew Haley
aph@redhat.com
Wed Aug 22 10:56:00 GMT 2012
On 08/21/2012 06:40 PM, Jeff B wrote:
> (int)floatVarA = 0.000000 <<=== initial value 0??
The initial value is zero because there is garbage in Float Register 0.
> floatVarA = 1234.000000
Now Float Register 0 contains 1234.0 .
> (int)floatVarA = 1234.000000 <<=== changed
Which gets printed out.
> floatVarB = 5678.000000
Now Float Register 0 contains 5678.0 .
> (int)floatVarA = 5678.000000 <<=== changed again
Which gets printed out.
> floatVarA = 1234.000000
etc...
Moral: undefined behaviour can do anything.
Andrew.
More information about the Gcc-help
mailing list