<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - terminate when throw not allowed type from set_unexpected handler"
   href="http://llvm.org/bugs/show_bug.cgi?id=16681">16681</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>terminate when throw not allowed type from set_unexpected handler
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vitaly.pavlenko@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>=== 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++.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>