[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g++ Bug? Why w/ and w/o "O3" options gives different result(g++3.3.3
From: |
Peng Yu |
Subject: |
Re: g++ Bug? Why w/ and w/o "O3" options gives different result(g++3.3.3) for this program? |
Date: |
Fri, 03 Dec 2004 18:38:02 -0600 |
Thank you for all the people replied my previous post.
The following minimum program shows that if you uncomment the
commented line, with and w/o -O3 option will give different results.
However, if you commented that line, with and w/o -O3 option will give
the same results.
If you make g_range_down an integer and uncomment the first cout
statement, the results will also be the same.
I wonder why the first cout statement and the declaration of
g_range_down as an array will affect the compile result.
g++3.3.3 is used.
Thanks,
Peng
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
double g_range_down[3];
g_range_down[2] = - 0.5;
// cout << g_range_down[2] << endl;
cout << ceil(g_range_down[2] / 0.02) << endl;
}
On 01 Dec 2004 17:45:37 -0800, Paul Pluzhnikov
<ppluzhnikov-nsp@charter.net> wrote:
>Peng Yu <pengyu.ut@gmail.com> writes:
>
>> Does it indicate g++ has a bug?
>
>We can't tell: your test case is too long, and nobody so far has
>shown inclination to spend hours analyzing it.
>
>Try to produce a *minimal* test case that demonstrates the problem.
>
>> Or I used some C++ language feature
>> that -O3 option doesn't support?
>
>It is quite a bit more likely that you have a bug in your program,
>but finding it without a minimal test case is difficult.
>
>FWIW, your program is "valgrind-clean", but shows reading
>uninitialized memory from stack under Chaperon (with and without -O3):
>
>[PC: 0x402c0835 std::ostream::operator<<()+0x000000a5] (Thread 0)
>**READ_UNINIT_MEM(read)**
>
> Reading uninitialized memory.
>
> Pointer : 0xbfffda25
> Stack trace where the error occurred:
> std::ostream::operator<<() pc: 0x402c0835
>std::basic_ostream<char, std::char_traits<char> >& std::operator<< <double,
>char, std::char_traits<char> >() pc: 0x080498a6
>/usr/include/c++/3.2.2/complex, 393
> main() pc: 0x0804931d junk.cc, 106
>
>temp = (0.0140056,0)
>temp = (0.0140056,0)
>
>Cheers,