c++ - gcc compiler optimizations affected code -


unfortunately not working open code right now, please consider question of pure theoretical nature. c++ project working seems crippled following options , @ least gcc 4.3 - 4.8 causing same problems, didn't notice trouble 3.x series (these options might have not been existed or worked differently there), affected platforms linux x86 , linux arm. options automatically set o1 or o2 level, had find out first options causing it:

tree-dominator-opts

tree-dse

tree-fre

tree-pre

gcse

cse-follow-jumps

its not own code, have maintain it, how possibly find sources of trouble these options making. once disabled optimizations above "-fno" code works. on side note, project work flawlessly visual studio 2008,2010 , 2013 without noticeable problems or specific compiler options. granted, code not 100% cross platform, parts windows/linux specific i'd know what's happening here. it's no vital question, since can make code run flawlessly, still interested how track down such problems.

so make short: how identify , find affected code?

i doubt it's giant gcc bug , maybe there not real fix code working with, it's of real interest me. take of these options eliminations of kind , read explanations these, still have no idea how start here.

first of all: try using debugger. if program crashes, check backtrace places faulty function. if program misbehaves (wrong outputs), should able tell occurs placing breakpoints.

if didn't , project small, try compiling subset of project "-fno" options stop program misbehaving. brute-force way finding smallest subset of faulty .cpp files , work way there. note: finding search algorithm complexity save lot of time.

if, chance, there single faulty .cpp file, further factor contents several .cpp files see functions cause of misbehavior.


Comments