Re: gcc 4.2.2: unexpected difference in behavior between -O0 and -Ox for x = 1, 2, 3

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

 



On 5/3/08, Benj FitzPatrick <benjfitz@xxxxxxxxx> wrote:
> I forgot to include
>
>  return(integral);
>
>  My question is why does the buggy code give the
>  correct answer with no optimizations, but an incorrect
>  answer with optimizations turned on?

Because by chance, without optimisation, your "integral" variable
happens to be stored (or a copy of its value happens to be left) in
the same register or stack location as the default place for function
call results.  I would guess it's the first item on the stack while
the function is alive and the first item after the top of the stack
when it return.

   M

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux