[llvm-bugs] [Bug 48085] New: Compiling infinite goto loop with -O2 takes clang into an infinite loop

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 5 01:15:49 PST 2020


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

            Bug ID: 48085
           Summary: Compiling infinite goto loop with -O2 takes clang into
                    an infinite loop
           Product: new-bugs
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: david.cortes.rivera at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24137
  --> https://bugs.llvm.org/attachment.cgi?id=24137&action=edit
Source code that produces the bug

I’ve come across an issue in which, when some C code contains an infinite loop
in the form of a ‘goto’ with the exit condition blocked by another goto,
compiling it with clang will take clang into an infinite loop during
compilation, making it get stuck until eventually running out of memory.

Attached is a screenshot of the source code that gave the problem (the original
file is this:
https://github.com/david-cortes/cmfrec/blob/master/src/collective.c).

I’m additionally attaching a very small reproducible example in which the issue
is reproducible, but only with -O2 and higher.

Steps to reproduce:
- Download the attached source code file
- Compile it with -O2 - e.g.:
    clang -O2 infinite_loop.c

Expected behavior: Should compile the source code into an executable,
regardless of whether it has an infinite loop or not. Ideally should warn about
the infinite loop.

Actual behavior: Compiler gets stuck into an infinite loop trying to optimize
that code, until eventually running out of memory.

-- 
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/20201105/a29b1869/attachment.html>


More information about the llvm-bugs mailing list