• 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: GCC 4.0 compiled code behaves differently with Debug on
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC 4.0 compiled code behaves differently with Debug on


  • Subject: Re: GCC 4.0 compiled code behaves differently with Debug on
  • From: Ken Baer <email@hidden>
  • Date: Wed, 21 Dec 2005 09:25:51 -0800

Well, after I posted the original message to this thread, I realized that the optimization is different between Debug and Release compiler settings. So, I started playing with the optimization for my release build. I discovered that if reduce the optimization from Fastest to Fast, the code works properly. Now this code is identical to code that works with Fastest/Smallest using the gcc 3.3 compiler. I will look into using Guard Malloc, but I am still suspicious of the compiler.

On Dec 20, 2005, at 4:14 PM, Eric Albert wrote:

On Dec 20, 2005, at 3:44 PM, Ken Baer wrote:

I have recently switched to GCC 4.0 for my application (a large one
that was using GCC 3.3).  I have encountered some odd behavior in
code that worked fine when compiled with GCC 3.3.  But, when I put
debug in the relevant files, the problem goes away.  Now, in the
past, I have seen this kind of thing happen because there were un-
initialized local variables being used.  Their values might not be
zero, but when they are compiled with Debug, those variable are now
automatically initialized to zero, and the problem goes away.

For what it's worth, building with -O0 doesn't automatically initialize variables to 0. It makes it more likely that you'll end up with 0 as a default value, but it doesn't guarantee it.

But, in this case, there are no un-initialized variables, so that's
not the problem.  I'd like to know if there are other known
behaviors, or known compiler bugs that would explain this that I
should look out for.

I also have another situation where I'd get a crash in a file, and
it would go away when I put debug in it.  So, I started putting in
printf()s to debug it, and having the printf() in it made it run
fine.  I cut it down to one printf( "\n" ); which still works.  Can
anyone shed some light on why this would work?  It's not the
ultimate solution I'm looking for.

I'm trying to get some more information and understanding of what's
going on, so I can make my app work without putting in Debug.

This is very unlikely to be a compiler bug. It isn't impossible, but code generation bugs in the compiler are exceedingly rare.

I'd suggest running with Guard Malloc enabled (it's near the bottom
of the Debug menu in Xcode) and seeing if that crashes.  If so, your
application is stomping on memory somewhere.  You might also have a
thread safety bug or something like that.  Those aren't much fun to
track down.

-Eric

_______________________________________________ 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: GCC 4.0 compiled code behaves differently with Debug on
      • From: Paul Russell <email@hidden>
References: 
 >GCC 4.0 compiled code behaves differently with Debug on (From: Ken Baer <email@hidden>)
 >Re: GCC 4.0 compiled code behaves differently with Debug on (From: Eric Albert <email@hidden>)

  • Prev by Date: Re: old errors not cleared out
  • Next by Date: Re: C++ Anyone
  • Previous by thread: Re: GCC 4.0 compiled code behaves differently with Debug on
  • Next by thread: Re: GCC 4.0 compiled code behaves differently with Debug on
  • Index(es):
    • Date
    • Thread