bug with -O2 in g++ Debian 4.0.2-9 ?

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

 



Here is the faulty program (this kind of code is generated by
http://www.swig.org):

/////////// Start ///////////
#include <stdio.h>

int main(void)
{
    long long a = 0x77777777L;
    long long b = 0;
    void ** aa=(void **)(void *)&a;
    void ** ab=(void **)(void *)&b;
    *ab = *aa;
    printf("in: %llX, out: %llX\n", a, b);
    return 0;
}
/////////// End ///////////

The output for the following version is:
(Debian 1:3.3.6-12) g++     in: 77777777, out: 77777777
(Debian 1:3.3.6-12) g++ -O1 in: 77777777, out: 77777777
(Debian 1:3.3.6-12) g++ -O2 in: 77777777, out: 77777777
(Debian 4.0.2-9) g++        in: 77777777, out: 77777777
(Debian 4.0.2-9) g++ -O1    in: 77777777, out: 77777777
(Debian 4.0.2-9) g++ -O2    in: 77777777, out: 0

So there is something wrong with g++ -O2 (Debian 4.0.2-9). Is this program wrong
or is this a bug ?

Regards,

Jerome

[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