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 Tue, Aug 21, 2012 at 10:40 AM, Jeff B <a.GNUbie@xxxxxxxxxxxx> 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


[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