This is the mail archive of the gcc-bugs@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 c++/51672] New: The optimization flags O2 & O3 produces wrong code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51672

             Bug #: 51672
           Summary: The optimization flags O2 & O3 produces wrong code
    Classification: Unclassified
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: benmeida@hotmail.com


Created attachment 26180
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26180
preprocessed file

Compiling with the optimization flags O2 & O3 produces wrong code & wrong
results. But with the flag O1 or O2, the program output the correct results :

3
1
2
0

O2 & O3 flags output :

65535
1
2
0

Compiled by : g++ -g -O3 -W -Wall -mtune=native -march=native -msse3
test_all.cpp -o test_all

Using :
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.2.1
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64
--with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.2
--enable-version-specific-runtime-libs --without-system-libunwind
--with-cpu=generic --host=x86_64-suse-linux
Thread model: posix
gcc version 4.2.1 (SUSE Linux)


The wrong assembly part marked by ! with (-O3):

  400b0a:    48 ba 0f 00 0f 00 0f     mov    $0xf000f000f000f,%rdx
  400b11:    00 0f 00 
  400b14:    48 33 11                 xor    (%rcx),%rdx
!  400b17:    66 c7 04 41 0f 00        movw   $0xf,(%rcx,%rax,2) "Insert
function"
  400b1d:    66 83 fa 01              cmp    $0x1,%dx
  400b21:    48 89 d0                 mov    %rdx,%rax


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]