<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Windows x64 SEH __except filter continuing to __finally gets UD2"
   href="https://llvm.org/bugs/show_bug.cgi?id=30747">30747</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Windows x64 SEH __except filter continuing to __finally gets UD2
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>nb@ravenbrook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=17465" name="attach_17465" title="C source with detailed disassembly in comment">attachment 17465</a> <a href="attachment.cgi?id=17465&action=edit" title="C source with detailed disassembly in comment">[details]</a></span>
C source with detailed disassembly in comment

Clang 3.8.0 on Windows 7, when compiling a __try { ... } __except (...) { ...}
inside a __try { ... } __finally { ... }, the __finally { ... } clause
generates a cleanup function which is garbled and includes a UD2.  I believe
that the semantics of this are well-defined, and I get sensible behaviour with
Visual Studio compilers.  Here's my code snippet, and attached is a detailed
disassembly in which I've picked apart the UNWIND_INFO and ScopeRecords and so
forth.

int f(void)
{
    int x = 3;
    __try {
        __try {
            g(3, &x);
        } __except((x == 42) ? EXCEPTION_EXECUTE_HANDLER :
EXCEPTION_CONTINUE_SEARCH) {
            x = 7;
        }
    } __finally {
    ++x;
    }
    return x;
}</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>