http://llvm.org/bugs/show_bug.cgi?id=14973

             Bug #: 14973
           Summary: infinite loop optimized away
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


We have found an inconsistency in the following testcase (derived from
pr33992.c in the gcc testsuite) using clang 3.2 and trunk.  When compiled
without optimization, the loop does not terminate.  However, with -O1 or above,
clang optimizes away the loop.  This behavior appears incorrect, as overflow
behavior is well defined with unsigned int.  Using -fwrapv and -ftrapv does not
change this result.

$ clang -O0 reduced.c
$ ./a.out 
^C [hangs]
$ clang -O1 reduced.c
$ ./a.out 
$ clang -v
clang version 3.3 (trunk 172630)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ cat reduced.c
void foo () 
{
  unsigned int i = 0;

  for (i = 0; ; i++) { }
}

int main()
{
  foo();

  return 0;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to