Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!news.snarked.org!newsfeed.news.ucla.edu!usenet.stanford.edu!news.iecc.com!nerds-end From: Shankar Newsgroups: comp.compilers Subject: Re: GCC/G++ compiler: Error goes away when run through debugger Date: Fri, 1 Apr 2011 15:31:09 -0700 (PDT) Organization: Compilers Central Lines: 24 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <11-04-003@comp.compilers> References: <11-03-054@comp.compilers> <11-03-061@comp.compilers> <11-03-063@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: gal.iecc.com 1301787969 41930 64.57.183.58 (2 Apr 2011 23:46:09 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 2 Apr 2011 23:46:09 +0000 (UTC) Keywords: GCC, debug, optimize Posted-Date: 02 Apr 2011 19:46:09 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: x330-a1.tempe.blueboxinc.net comp.compilers:70 On Mar 29, 2:42 pm, i...@localhost.claranet.nl (Ike Naar) wrote: > George Neuner wrote: > > >GCC's -O3 optimization level is widely known to cause strange problems > >... almost always because the program is violating assumptions made by > >the more advanced optimizations. > > >The -O2 level typically is safe. If you think you need the -O3 > >optimizations, you should individually enable them to see if any > >breaks the program. Specify -O3 only if you find they all work. > > Sometimes using -O3 makes the program run slower than when using -O2. I think you should use some tool like valgrind which might immediately catch the problem that would be going on. Also when you use -ggdb I think some of the strings are loaded in the .data section but gets loaded into the .const data section otherwise. - Shankar