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++/30245] New: -O2 generates bad code


I compiled the following C++ code on a x86_64 machine
without optimisation.

#include <iostream.h>

int
main()
{
        long long n = 1;

        cout << sizeof( n) << endl;
        for (int i = 0; i < 100; ++i)
        {
                cout << n << ' ' << (float) n << '\n';
                n *= 2;
                if (n == 0)
                {
                        break;
                }
        }
        return 0;
}

When the compiled code runs, it is fine.
There are 64 executions of the loop.

However, I added flag -O2, and the code runs differently.
There are 100 executions of the loop.

Suspect optimiser bug.


-- 
           Summary: -O2 generates bad code
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dcb314 at hotmail dot com
  GCC host triplet: x86_64-pc-linux


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


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