How to protect the function of unpredictable behavior after change of optimization level of compiler (C programming)? -


i have lot of problems related optimization level of gcc compiler. behavior of c routines dramatically changed when set compilation level higher, , not work expected. gcc compiler part of atollic truestudio ide.

does can give me advice on topic? universal approach in solution of kind of problem?

my apologize if i'm not 100% precise.

write better code. correct code not change behavior different optimization levels.

avoid:

  • undefined behavior. shouldn't need mentioning, it's important since gcc using assumption "code doesn't trigger ud" drive optimizations.
  • implementation-specified behavior. these might change different optimization flags. perhaps not common, think can happen.

use compiler warnings, linters , other static analysis tools find errors in code (or, of course, debug problems see when turn on optimization).


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -