Possible advantage
Possible advantage
Posted Jun 17, 2008 21:38 UTC (Tue) by roelofs (guest, #2599)In reply to: Possible advantage by giraffedata
Parent article: Implications of pure and constant functions
But when I debug at the machine level I add -O0 to the compile options. That's usually described as "don't optimize", but as I consider optimization to be an integral part of the compiler's job, I view it as, "Make the machine program track the source code as closely as possible."
"...and watch your bug go away." :-)
That seems to happen to me more often than not. Most recently it turned out to be a gcc code-generation bug, 32-bit only, 3.4.x only. (Pretty sure not related to const, though C++ is a different beast, so I'm not 100% certain.)
Greg
      Posted Jun 18, 2008 2:00 UTC (Wed)
                               by giraffedata (guest, #1954)
                              [Link] 
       
Of course, this is mostly with older compilers.  (The new ones are too slow for me).
      
           
     
    
      Of all the bugs I've analyzed with GDB, I'd say about 5% stop manifesting when I disable optimization.  One was a compiler optimizer bug, one was me lying to the compiler (unintentionally, of course), and the rest were wild pointers causing stack corruption.
Possible advantage
      
 
           