• 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: Function's default values are corrupted (Nasty bug)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function's default values are corrupted (Nasty bug)


  • Subject: Re: Function's default values are corrupted (Nasty bug)
  • From: Chris Espinosa <email@hidden>
  • Date: Wed, 30 Mar 2005 13:10:50 -0800

On Mar 30, 2005, at 12:49 PM, Dave Thorup wrote:

I've got the following function whose default values are being corrupted when it is called:


IError * SetSize( unsigned long nWd, unsigned long nHt,

    long nEx1 = -1, long nEx2 = -1, long nEx3 = -1, long nEx4 = -1 );


When this is called like this:


//    nWd=4028, nHt=1324, nExtra=20

SetSize( nWd, nHt, nExtra );


Then the actual values that I see inside the function are as follows:


nWd=4028, nHt=1324, nEx1=20, nEx2=0, nEx3=0, nEx4=0


But nEx2, nEx3 and nEx4 should all be set to -1.


I have no idea why this is happening.  The same code works fine from CodeWarrior and on Windows using Visual Studio.  Why are GCC (3.3) & Xcode (1.5) getting messed up?


Has anyone else seen anything like this?  I tried creating a simple test case but I cannot reproduce the problem with it.  I expect it's something really nasty so I'm hoping someone else has seen this and can point me in the right direction.


What optimization level are you running at?  If you have optimized code, the default assignments may not be made until the variables are actually used in the function.

How can you tell the values are 0?  Do you printf() them, or are you looking at them in the debugger?

If you do not actually use nEx1 through nEx4 inside the routine, the compiler may neglect to allocate space for them or copy them, and the debugger will of course show you irrelevant values.

Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: Function's default values are corrupted (Nasty bug)
      • From: Dave Thorup <email@hidden>
References: 
 >Function's default values are corrupted (Nasty bug) (From: Dave Thorup <email@hidden>)

  • Prev by Date: Re: can't open library
  • Next by Date: Returned mail: User unknown
  • Previous by thread: Function's default values are corrupted (Nasty bug)
  • Next by thread: Re: Function's default values are corrupted (Nasty bug)
  • Index(es):
    • Date
    • Thread