• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem using static floats
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem using static floats


  • Subject: Re: Problem using static floats
  • From: Scott F Bayes <email@hidden>
  • Date: Sat, 21 Jul 2007 20:10:29 +0900

Hi Shawn,

No, this wasn't the return value. This was on of the arguments being received as garbage by the method parameters. Saw it while execution was in the method. Debugger was actually pretty helpful for a change, and the code was free-running with the same kind of symptoms (being random-appearing, I can't guarantee it was the same problem for sure, but the odds are on it).. If I spoke IA-32, I probably could detect the flaw in the debugger disassembly, but 68K was my last assembly fluency. From what I could glean, looks like doubles are passed as a reference on the stack, whereas floats look to be passed by value on the stack (though it could be it's an ivar reference), but am not sure. My guess is that the 4 bytes received for the float are taken from where the float ain't.

Best Regards


ScottB

On Jul 20, 2007, at 02:37 , Shawn Erickson wrote:

On 7/19/07, Scott F Bayes <email@hidden> wrote:
Hi Joel,

I saw something somewhat similar a few days ago and submitted a bug
report. No response yet. 10.4.10 on an original MacBook, latest
Xcode, stock standard.

In my case, passing a float into an Obj-C instance method failed.
Just before the method call, the debugger showed the expected value
in my float variable. On the other side, inside the method, the
incoming float argument was essentially a random number. When I
changed to a double, it worked fine. So did an int.

This sounds like the caller assuming the return type to be something other then what the implementation expected. Did you get any compiler warnings about it assuming the return type for a message?

It is highly likely that the calling code doesn't have visibility of
the methods declaration and as a result assumes the return type to be
id (a pointer) which is default return type for objective-c messages.
Pointers (integers) are passed in different registers the floats and
as a result the caller is looking in the wrong registers on return
from the method.

-Shawn


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Problem using static floats (From: Joel Norvell <email@hidden>)
 >Re: Problem using static floats (From: Scott F Bayes <email@hidden>)
 >Re: Problem using static floats (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: -install_path woes
  • Next by Date: Issues with LSOpenFromRefSpec
  • Previous by thread: Re: Problem using static floats
  • Next by thread: Re: Problem using static floats
  • Index(es):
    • Date
    • Thread