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 Wed, Aug 22, 2012 at 6:58 AM, Jeff B <a.GNUbie@xxxxxxxxxxxx> wrote:
>
> OK, then I guess the presence of the cast makes it OK for the compiler
> to pull the bits for a variable from somewhere other than where the
> variable actually is.

No.

As I said before, the problem is the calling convention.  printf with
%f expects a float argument.  You are passing it an int argument.  A
float argument is passed in a float register.  An int argument is
passed in a general register.  printf sees %f and looks in a float
register.  You are passing the value in an int register.  Since you
are not passing the value in a float register, printf is printing
random bits that you never passed.

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