Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dominover on July 15, 2014, 10:15:08 am

Title: Optimize even more (for speed) [-02] ?
Post by: dominover on July 15, 2014, 10:15:08 am

In the compiler flags for Code::Blocks version 13.12 the flag Optimize even more (for speed) [-02] is checked for Release Versions.

While my program will compile fine (without errors) when this is checked, I get a fatal error during run-time.

I have subsequently unticked this box. Deleted the object files and recompiled the program and it works fine during run-time.  I'm wondering why this would cause an error?  Are there any common reasons why this would happen?   

Thanks
Dom
Title: Re: Optimize even more (for speed) [-02] ?
Post by: stahta01 on July 15, 2014, 01:51:50 pm
I have never had this problem; but, the posts I read about others having it are:

1. Compiler Bug
2. User code does something undefined by the C/C++ standard therefore user error.

Neither of the above causes are things permitted on this forum. http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)

I can think of no other causes of this bug.

Tim S.
Title: Re: Optimize even more (for speed) [-02] ?
Post by: dominover on July 15, 2014, 01:58:42 pm
Hmm.. Thanks.. I have never had it before so it's a complete mystery. 
I know that debug versions can mask certain errors but in this case there doesn't seem to be any. 
A complete mystery ???
Title: Re: Optimize even more (for speed) [-02] ?
Post by: oBFusCATed on July 15, 2014, 09:09:30 pm
This is most probably some uninitialized variable or memory somewhere in your program.
If you're using threads it might be some race condition.

There are plenty of tools you can use to find it: compiler warning, debugger, printf, valgrind, clang address sanitizer, etc...