<html>
    <head>
      <base href="http://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 --- - Inliner can drop "cleanup" clause when inlining; C++ destructors not run"
   href="http://llvm.org/bugs/show_bug.cgi?id=17872">17872</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inliner can drop "cleanup" clause when inlining; C++ destructors not run
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </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>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mseaborn@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>isanbard@gmail.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>InlineFunction.cpp doesn't look at the "cleanup" flag on landingpad
instructions.  If it inlines an inner "invoke" instruction without "cleanup"
into an "invoke" call site with "cleanup", the latter's "cleanup" flag is lost.

This can lead to C++ destructors not being called when an exception is thrown.

Here's an example.  This prints "in cleanup" at -O0 but not at -O2:


#include <stdio.h>

class MyClass {
public:
  ~MyClass() { printf("in cleanup\n"); }
};

class DummyException1 {};
class DummyException2 {};

void throw_func() {
  throw 1;
}

static void inner() {
  try {
    throw_func();
  } catch (DummyException1 &) {}
}

void outer() {
  MyClass x;
  try {
    inner();
  } catch (DummyException2 &) {}
}

int main() {
  try {
    outer();
  } catch (int) {}
  return 0;
}</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>