From: | "BartC" <bc@freeuk.com> |
Newsgroups: | comp.compilers |
Date: | Mon, 28 Mar 2011 11:34:01 +0100 |
Organization: | A noiseless patient Spider |
References: | 11-03-054 |
Keywords: | C++, debug |
Posted-Date: | 29 Mar 2011 11:53:21 EDT |
<rhoads@cs.rutgers.edu> wrote in message news:11-03-054@comp.compilers...
> 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?
You have a bug in your application, which is probably not just
incorrect logic, but something more serious. (Does it crash or just
give the wrong output?)
Possibly ask in a language forum such as comp.lang.c++, where you may
be asked to show sample code. (Also you will get feedback quicker than
on a moderated group.)
You need to do everything you can to make the error persistent, rather
than make it go away. And to try and narrow down the place where it
occurs.
Your compiler may also have options to turn on warnings for suspect
constructions; try turning on everything...
--
Bartc
Return to the
comp.compilers page.
Search the
comp.compilers archives again.