• 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: Dave Thorup <email@hidden>
  • Date: Wed, 30 Mar 2005 17:09:50 -0500

On Mar 30, 2005, at 4:10 PM, Chris Espinosa wrote:

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.

Well, I was first running with No optimizations (-O0). But I've since tried with -O3 with the same results.


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

My first indication was that I was hitting an ASSERT as a result of getting bad values from the SetSize function. Then as I traced through in the debugger I saw the behavior that I described. I've since also printed to the console (via std::cout) and get the same results there as I do 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.

The values are all passed, along with some member variables, to a protected method that uses all of them. That method uses all of the values to allocate memory. If -1 is passed then a default amount of memory is allocated, but when 0 is passed then no memory is allocated and I run into memory access errors later on. So when nEx2 - 4 are set to 0 instead of -1 then all Hell breaks loose.


This one is really nasty and driving me crazy. I've tried to create a simple project to reproduce it, but so far I've been unsuccessful.
_____________________________


Dave Thorup
Software Engineer
email@hidden

http://www.kuwan.net
Defaults Manager - The premier editor for Mac OS X's User Defaults / Preferences database.


_______________________________________________
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: 
 >Function's default values are corrupted (Nasty bug) (From: Dave Thorup <email@hidden>)
 >Re: Function's default values are corrupted (Nasty bug) (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: XCode basic questions - help
  • Next by Date: splitting output in gdb
  • Previous by thread: Re: Function's default values are corrupted (Nasty bug)
  • Next by thread: Re: Function's default values are corrupted (Nasty bug)
  • Index(es):
    • Date
    • Thread