Re: Calling a function with a float argument modifies caller's state.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux