[LLVMbugs] [Bug 16681] New: terminate when throw not allowed type from set_unexpected handler

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 23 05:39:06 PDT 2013


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

            Bug ID: 16681
           Summary: terminate when throw not allowed type from
                    set_unexpected handler
           Product: libc++
           Version: 3.2
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: vitaly.pavlenko at intel.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

=== SOURCE ===
// checking for class std::bad_exception
#include <stdio.h>
#include <exception>

using namespace std;

void bad_exception ();

void foo () throw (std::bad_exception)
{
  // throw an object of a disallowed type
  throw 0;
}

void handler ()
{
  // throw an object of a type not allowed by the exception-specification
  // of the function that already violated its specification (due to which
  // the handler has been called); this requires the exception object to be
  // replaced by the runtime library by one of type [std]::bad_exception
  throw "";
}

int main ()
{
    std::set_unexpected (handler);
    try {
      // will fail if runtime library doesn't recognize std::bad_exception
      // by calling terminate()
      foo ();
    }
    catch (std::bad_exception&) {
      printf("return 0 - PASSED\n");
      return 0;
    }
    catch (...) {
       printf("return 1 - FAILED\n");
      return 1;
    }
    printf("return 2 - FAILED\n");
    return 2;
}


=== EXPECTED (LIBSTDC++) OUTPUT ===
return 0 - PASSED


=== REAL (LIBC++) OUTPUT === 
$ ./a.out
libc++abi.dylib: terminate called throwing an exception
Abort trap: 6
$ echo $?
134


=== COMPILER ===
$ clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.0.0
Thread model: posix


=== ADDITIONAL ANALYSIS ===
This is library problem, because the Intel compiler's outputs are the same on
options -stdlib=libc++ and -stdlib=libstdc++.

-- 
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/20130723/42066604/attachment.html>


More information about the llvm-bugs mailing list