<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Compiling infinite goto loop with -O2 takes clang into an infinite loop"
   href="https://bugs.llvm.org/show_bug.cgi?id=48085">48085</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiling infinite goto loop with -O2 takes clang into an infinite loop
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david.cortes.rivera@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24137" name="attach_24137" title="Source code that produces the bug">attachment 24137</a> <a href="attachment.cgi?id=24137&action=edit" title="Source code that produces the bug">[details]</a></span>
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:
<a href="https://github.com/david-cortes/cmfrec/blob/master/src/collective.c">https://github.com/david-cortes/cmfrec/blob/master/src/collective.c</a>).

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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>