<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 - Miscompilation when using -g, -fmodules and non-module headers"
   href="https://bugs.llvm.org/show_bug.cgi?id=42955">42955</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompilation when using -g, -fmodules and non-module headers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>Modules
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yshuiv7@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have not idea what is causing this, but here is the code that triggers the
bug:

<a href="https://github.com/yshui/bugs/tree/clang-8.0.1-2019-08-19">https://github.com/yshui/bugs/tree/clang-8.0.1-2019-08-19</a>

The clang command is in test.sh.

The miscompiled function is __list_insert_between, 

    new_->prev = prev;

is somehow compiled as

    new_->next = prev;

Doing either of these fixes the problem:

* Remove -g from clang command line
* Include "list.h" directly in x.c
* Remove the "triggers_the_bug" function

Tested on 8.0.1 and 9.0.0 r366556 (or git commit
1931d3cb20a00da732c5210b123656632982fde0)</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>