Re: GCC 4.0 compiled code behaves differently with Debug on
Re: GCC 4.0 compiled code behaves differently with Debug on
- Subject: Re: GCC 4.0 compiled code behaves differently with Debug on
- From: Eric Albert <email@hidden>
- Date: Tue, 20 Dec 2005 16:14:47 -0800
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