Re: gcc4 optimization problems on intel mac
Re: gcc4 optimization problems on intel mac
- Subject: Re: gcc4 optimization problems on intel mac
- From: Paul Walmsley <email@hidden>
- Date: Tue, 23 Jan 2007 21:34:46 +0000
Both of these problems only existed in our release builds, and after
some tweaking and testing, I determined that the problem was related
specifically to the optimization settings in GCC4. Under *any*
setting except -O0, these strange behaviors would reappear, though
without optimization everything runs normally.
I wouldn't necessarily assume that the bug is in compiler's optimisation
(though of course it can never be ruled out). I've come across many
'release build only' bugs in the past that have emerged as a result of
the various differences between debug and release builds. A few of the
things to try would be:
* Isolate a minimal reproducible case where this incorrect behaviour
occurs
* Look out for uninitialised variables -- I don't know if gcc does
this, but I know that MSVC zero-initialises variables in a debug
build but not in a release build. I've found this to be the
number one case of release-build-only bugs.
* Try different combinations of defining _DEBUG and enabling
optimisation (eg an optimised debug build, or a non-optimised
release build).
* Try toggling inlining
* Ensure that all other dependent libraries are using exactly the
same preprocessor macros -- one thing to look out for is classes
that have several functions or variables surrounded by #ifdef (as
this would mean that sizeof() would return different values
depending on where it was called), also check that you're linking
against the correct (debug or release) versions of any libraries.
The order of inclusion of headers may differ in release builds due
to the prevailing preprocessor macros.
* Rebuild your source and check *all* compiler warnings
* Don't use C-style casts. I came across a really nasty bug a while
ago caused by a combination of a C-style cast and the different
order of inclusion in a release build (which meant a type was
incomplete). Use static_cast, dynamic_cast and reinterpret_cast
and the compiler will tell you if the conversion is unsafe.
Release-build only bugs are a pain. But think of it as character
building...
Paul
_______________________________________________
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