Calling a function with a float argument modifies caller's state.
Ian Lance Taylor
iant@google.com
Wed Aug 22 09:04:00 GMT 2012
On Tue, Aug 21, 2012 at 10:40 AM, Jeff B <a.GNUbie@myletters.us> wrote:
>
> Well, a variable I am able to access from main() is changing
> even tho there is nothing in main() itself which is changing it.
Your program does not demonstrate that that has happened.
> I agree about using code with undefined behavior. Regardless
> of whatever confusion printf() may have about how to actually
> print something, it seems to me that (int)floatVar ought to be
> getting the bits from the same place as (float)floatVar. Is that
> not true?
It is not true.
To understand why it is not true, see the x86 calling conventions.
They pass int and float arguments in different places.
Ian
More information about the Gcc-help
mailing list