bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug?


From: Benoit Hudson
Subject: Re: Bug?
Date: Fri, 29 Sep 2000 15:17:28 -0400

On Fri, Sep 29, 2000 at 08:38:38PM +0200, Eugen Dedu wrote:
> Hi,
> 
> I do not know if it is really a bug.
> 
> My program stops to an assertion (with abort).  I examine the core file
> and here is what happens (compiled with gcc -O0 -ggdb):
> --
> eminescu:~/abc/parmass2$ gdb a.out core 
> [...]
> (gdb) p nb
> $1 = 4
> --
> The same program compiled with -O3 instead of -O3 gives:
> --
> eminescu:~/abc/parmass2$ gdb a.out core 
> [...]
> (gdb) p nb
> $1 = 6
> --
> 
> The correct variant is the first (I looked in the program too).  So if
> you think this is a bug (the value of a parameter is different if
> compiled with -O0 or with -O3) please let me know.  I will send you more
> information.


Optimization lets the compiler do weird things; the compiler has probably
determined one of:
        it's safe to set nb earlier or later in the function than what you
                wrote, and it's advantageous to do so
        nb is no longer used, so some other variable can use the same
                register or memory address now
        nb is used in such a way that the compiler can determine
                how to set it to a different value but get the same 
                results, and it's advantageous to do so

This is one reason many compilers don't allow compiling with both debugging
and optimization -- that it's confusing to debug an optimized program.

        -- BenoƮt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]