This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Calling a function with a float argument modifies caller's state.
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.