[llvm-bugs] [Bug 25997] [WinEH] no-return function in cleanup code not called with -O

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 2 11:56:21 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=25997

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |david.majnemer at gmail.com,
                   |                            |rnk at google.com
         Resolution|---                         |WONTFIX

--- Comment #1 from David Majnemer <david.majnemer at gmail.com> ---
Thanks for the excellent bug report!

This seems to be a quirk in the behavior of MSVC's personality routine.

C++17 [except.handle]p9 says:
If no matching handler is found, the function std::terminate() is called;
whether or not the stack is unwound before this call to std::terminate() is
implementation-defined.

Clang has decided that your catch handler is not a matching handler because it
is dynamically unreachable.

Here is an example which doesn't rely on clang-cl.  clang, gcc and icc give the
following code different behavior depending on the optimization level:
extern "C" void __attribute__((nothrow, noreturn)) exit(int);

struct S {
  ~S() { exit(1); }
};

void f() {
  S s;
  throw 0;
}

void g() {
  try {
    f();
  } catch (...) {
  }
}

int main() { g(); }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160102/ecb373d3/attachment.html>


More information about the llvm-bugs mailing list