GCC/G++ compiler: Error goes away when run through debugger

"rhoads@cs.rutgers.edu" <rhoads@cs.rutgers.edu>
Sat, 26 Mar 2011 12:35:22 -0700 (PDT)

          From comp.compilers

Related articles
GCC/G++ compiler: Error goes away when run through debugger rhoads@cs.rutgers.edu (rhoads@cs.rutgers.edu) (2011-03-26)
Re: GCC/G++ compiler: Error goes away when run through debugger nospam@no.spam (Mark in Sutherland) (2011-03-27)
Re: GCC/G++ compiler: Error goes away when run through debugger bobduff@shell01.TheWorld.com (Robert A Duff) (2011-03-27)
Re: GCC/G++ compiler: Error goes away when run through debugger robin51@dodo.com.au (robin) (2011-03-28)
Re: GCC/G++ compiler: Error goes away when run through debugger Pidgeot18@verizon.invalid (Joshua Cranmer) (2011-03-27)
Re: GCC/G++ compiler: Error goes away when run through debugger torbenm@diku.dk (2011-03-28)
Re: GCC/G++ compiler: Error goes away when run through debugger bc@freeuk.com (BartC) (2011-03-28)
[5 later articles]
| List of all articles for this month |

From: "rhoads@cs.rutgers.edu" <rhoads@cs.rutgers.edu>
Newsgroups: comp.compilers
Date: Sat, 26 Mar 2011 12:35:22 -0700 (PDT)
Organization: Compilers Central
Keywords: optimize, debug, question
Posted-Date: 27 Mar 2011 01:39:24 EDT

I have an C++ application program that is producing incorrect results
but the error goes away when I run it through the debugger.


I'm using the gcc/g++ compiler under Cygwin (an UNIX emulator that
runs on windows).


When I used the -ggdb compiler flag so I can run it under the gdb
debugger, the error goes away. It also runs fine if I do both of the
following; extract a few of the input instances which generate
incorrect results and put them in a separate input file.
Use this input file and recompile the program with no optimization
flags (I am otherwise using the -O3 optimization flag).


The -O3 optimizations are supposed to always produce the same
results. Running through the debugger is not supposed to change the
results either. Has anybody else encountered this behavior?
[The usual problem is that you're doing something that isn't valid
C, so the optimizer doesn't preserve its semantics. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.