<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 - Possible miscompilation by clang-cl versions 7, 8, and 9 targeting 32-bit Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=42567">42567</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Possible miscompilation by clang-cl versions 7, 8, and 9 targeting 32-bit Windows
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bspencer@blackberry.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22221" name="attach_22221" title="Program demonstrating the bug">attachment 22221</a> <a href="attachment.cgi?id=22221&action=edit" title="Program demonstrating the bug">[details]</a></span>
Program demonstrating the bug

The attached program, when compiled with clang-cl versions 7, 8, and 9 (from
apt.llvm.org for Debian stretch) crashes when targeting 32-bit Windows.  It
does not crash when targeting 64-bit Windows with clang-cl or when using MSVC
(15.9.12 and other versions).

The attached archive contains a (POSIX) Makefile that can build on Linux using
a selection of compilers.  Building with MSVC (on Windows or on Linux) always
produces an executable that works.  Building with clang-cl for 32-bit always
produces an executable that fails.

For example:

$ make
clang version 9.0.0-svn364966-1~exp1+0~20190702204433.1332~1.gbpb44072 (trunk)
LLD 9.0.0
INCLUDE="/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/ucrt;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/include;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/shared;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/um"
clang-cl-9 -Wno-unused-private-field -EHsc -analyze- -O2 -MD -W4 -WX -m32
-Wno-unused-private-field -c -Foprog.obj prog.cc
INCLUDE="/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/ucrt;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/include;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/shared;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/um"
clang-cl-9 -Wno-unused-private-field -EHsc -analyze- -O2 -MD -W4 -WX -m32
-Wno-unused-private-field -c -Folib.obj lib.cc
LIB="/home/bspencer/msvc2017-15.9.12/ucrt/Lib/10.0.17134.0/ucrt/x86;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/lib/x86;/home/bspencer/msvc2017-15.9.12/ucrt/Lib/10.0.17134.0/um/x86"
lld-link-9  /OUT:prog.exe prog.obj lib.obj

It fails both under Wine and real Windows:

$ wine ./prog.exe
Try!
Catch!
wine: Unhandled page fault on execute access to 0x2f409fde at address
0x2f409fde (thread 0023), starting debugger...

C:> prog.exe
Try!
Catch!
(Windows crash dialog box)

The crash happens in an std::thread function accessing an exception thrown and
caught within that thread.  Minimizing the test case further in any way that I
tried avoided the bug.</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>