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

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -