This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]