[llvm-bugs] [Bug 45106] New: Infinite loop with -O3

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 4 23:53:34 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=45106

            Bug ID: 45106
           Summary: Infinite loop with -O3
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: oyvind.harboe at zylin.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

this application completes immediately without -O3 and runs indefinitely with
-O3.

The application comes from the gcc-testsuite.

This is with clang-8.

$ cat gcc/gcc/testsuite/gcc.c-torture/execute/930529-1.c
/* { dg-options { "-fwrapv" } } */

extern void abort (void);
extern void exit (int);

int dd (int x, int d) { return x / d; }

int
main ()
{
  int i;
  for (i = -3; i <= 3; i++)
    {
      if (dd (i, 1) != i / 1)
abort ();
      if (dd (i, 2) != i / 2)
abort ();
      if (dd (i, 3) != i / 3)
abort ();
      if (dd (i, 4) != i / 4)
abort ();
      if (dd (i, 5) != i / 5)
abort ();
      if (dd (i, 6) != i / 6)
abort ();
      if (dd (i, 7) != i / 7)
abort ();
      if (dd (i, 8) != i / 8)
abort ();
    }
  for (i = ((unsigned) ~0 >> 1) - 3; i <= ((unsigned) ~0 >> 1) + 3; i++)
    {
      if (dd (i, 1) != i / 1)
abort ();
      if (dd (i, 2) != i / 2)
abort ();
      if (dd (i, 3) != i / 3)
abort ();
      if (dd (i, 4) != i / 4)
abort ();
      if (dd (i, 5) != i / 5)
abort ();
      if (dd (i, 6) != i / 6)
abort ();
      if (dd (i, 7) != i / 7)
abort ();
      if (dd (i, 8) != i / 8)
abort ();
    }
  exit (0);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200305/3449e110/attachment.html>


More information about the llvm-bugs mailing list