http://llvm.org/bugs/show_bug.cgi?id=17872

            Bug ID: 17872
           Summary: Inliner can drop "cleanup" clause when inlining; C++
                    destructors not run
           Product: tools
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

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;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to