[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


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

             Bug #: 11893
           Summary: When noexcept is violated clang should call
                    __cxa_begin_catch(unwind_arg) prior to calling
                    std::terminate
           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";
    std::abort();
}

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

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

void f2()
{
    std::set_terminate(handler1);
    throw std::runtime_error("throw in f2");
}

void f1() noexcept
{
    A a;
    f2();
}

int main()
{
    f1();
}

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
__cxa_begin_catch(unwind_arg).

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