This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]