public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33611]  New: Optimizations generate incorrect code
@ 2007-10-01 17:02 macracan at yahoo dot com
  2007-10-01 17:05 ` [Bug c++/33611] " macracan at yahoo dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: macracan at yahoo dot com @ 2007-10-01 17:02 UTC (permalink / raw)
  To: gcc-bugs

The following snipped when compiled with -O0 generates a program that quickly
finishes (correct behavior). But when compiled with any optimizations (-O1, -O2
or -O3) generates a program that never finishes. Variations on the code, (such
as the comment line) geneate valid program with either level of optimization.
Checked in 4.1.1 too (i386) and the bug is there too. Checked in 4.1.2 on
x86_64 and the bug is NOT there.

-- star of file aa.cpp
struct A
{
  unsigned int e;
};
A a = {1};
double f[] = {0.0461109, 0.285433};
int main(void)
{
  for (bool bEncore = true; bEncore; )
  {
    bEncore = false;
    double p = 0.422244 * f[a.e];
//    double p = 0.422244 * f[1];
    if (f[0] < p)
    {
      f[0] = p;
      bEncore = true;
    }
  }
  return 0;
}
-- end of file aa.cpp

g++ -O3 aa.cpp
./a.out           --> goes into infinite loop


-- 
           Summary: Optimizations generate incorrect code
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: macracan at yahoo dot com
 GCC build triplet: GNU/linux i386/i686
  GCC host triplet: GNU/linux i386/i686
GCC target triplet: GNU/linux i386/i686


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-01 17:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-01 17:02 [Bug c++/33611] New: Optimizations generate incorrect code macracan at yahoo dot com
2007-10-01 17:05 ` [Bug c++/33611] " macracan at yahoo dot com
2007-10-01 17:10 ` [Bug middle-end/33611] " pinskia at gcc dot gnu dot org
2007-10-01 17:16 ` [Bug middle-end/33611] [4.1/4.2/4.3 regression] " bangerth at dealii dot org
2007-10-01 17:43 ` macracan at yahoo dot com
2007-10-01 17:43 ` macracan at yahoo dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).