Re: [sigc] Incorrect memory read in libsigc++-2.0.3 when compiled without optimization



Andris Pavenis wrote:
>
> Noticed incorrect memory read in included example when it was compiled
> without optimizations (-O0). It's most likely a bug in GCC, as
> it doesn't appear with -O1 or -O2. Tested under Linux.

I am encountering a similar problem with libsigc++-2.0.3's test_lambda.cc
using gcc 3.2.2 on RedHat 9.0 and using MSVC++7.1 on Windows 2000.

With g++'s -O1/-O2/-O3 flags and with MSVC's /O1 or /O2 flags, test_lambda
outputs:

    ((++_1)*2)(a):      4; a: 1
    ((++_1)*2)(ref(a)): 4; a: 2
    ((++(*_1))*2)(&a):  6; a: 3
    ((--(*(&_1)))*2)(ref(a)): 4; a: 2
    ...
    bar::test(int 1, int 2)
    ...
    foo_void(int 2)

These values seem correct to me.

Curiously, with optimizations disabled in both compilers, I get different
results:

    ((++_1)*2)(a):      4; a: 1
    ((++_1)*2)(ref(a)): 4; a: 1
    ((++(*_1))*2)(&a):  6; a: 2
    ((--(*(&_1)))*2)(ref(a)): 4; a: 3
    ...
    bar::test(int -1073750888, int -1073750884)
    ...
    foo_void(int -1073750856)

(The first set of results are identical with gcc and MSVC; the garbage values
are different, though.)

Does anyone have any ideas about how to avoid this problem (aside from simply
enabling compiler optimizations)?

Thanks!

- James



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