[LLVMbugs] [Bug 11893] New: When noexcept is violated clang should call __cxa_begin_catch(unwind_arg) prior to calling std::terminate

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 30 18:00:11 PST 2012


             Bug #: 11893
           Summary: When noexcept is violated clang should call
                    __cxa_begin_catch(unwind_arg) prior to calling
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: hhinnant at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This test:

#include <iostream>
#include <stdexcept>
#include <exception>
#include <cstdlib>

void handler1()
    std::cout << "handler 1\n";

void handler2()
    std::cout << "handler 2\n";

struct A
    ~A() {std::set_terminate(handler2);}

void f2()
    throw std::runtime_error("throw in f2");

void f1() noexcept
    A a;

int main()

Should output:

handler 1

When run against the trunk libc++abi.   Note that the trunk libc++abi won't run
with the trunk libc++, but this will change soon (within a few days).

When the noexcept is violated, clang currently outputs a call to
std::terminate().  Just prior to that call clang needs to call
__cxa_begin_catch(unwind_arg) to make this work.

Reference [except.handle]/p7:

Also, an implicit handler is considered active when std::terminate() or
std::unexpected() is entered due to a throw.

With the Itanium ABI, the way you make a handler active is by calling

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list