[LLVMbugs] [Bug 18245] New: [C++98]Should continue search after unexpected() throw a exception allowed by exception-spec
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Dec 13 16:55:28 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=18245
Bug ID: 18245
Summary: [C++98]Should continue search after unexpected() throw
a exception allowed by exception-spec
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: zhaoshiz at codeaurora.org
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11731
--> http://llvm.org/bugs/attachment.cgi?id=11731&action=edit
test case for Sec 15.5.2
>From C++98 standard, Sec 15.5.2
The unexpected() function shall not return, but it can throw (or re-throw) an
exception. If it throws a new exception which is allowed by the exception
specification which previously was violated, then the search for another
handler will continue at the call of the function whose exception specification
was violated.
$ clang++ -target arm-none-linux-gnueabi -mfloat-abi=softfp -mfpu=neon
--sysroot=/prj/llvm-arm/home/common/build_tools/gcc-4.6.1-cs/arm-2011.09 -marm
-march=armv7-a 15.5.2.unexpected.cpp -o 15.5.2.unexpected.comm.exe -static
$ qemu-arm -cpu cortex-a15 ./15.5.2.unexpected.comm.exe
terminate called after throwing an instance of 'B'
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted
$ cat 15.5.2.unexpected.cpp
#include <exception>
#include <cstdlib>
#include <cstdio>
class B {
public:
const char *s;
B(const char *p) : s(p) {}
B() : s("NULL") {}
};
class D : public B {
public:
const char *t;
D(const char *p) : B(p), t(p) {}
D() : B(), t("NULL") {}
};
static void boo() {
printf("UNREACHABLE!\n");
}
static void foo() throw (D, const char*) {
throw B("x"); // violates exception-specification
}
static void goo() {
try {
foo();
} catch (const B &b) {
boo(); // should not reach here, given above expection-spec unexpected is
called
} catch (const char *s) {
exit(3);
}
boo(); // should not reach here
}
/*
Sec 15.5.2
The unexpected() function shall not return, but it can throw (or re-throw) an
exception. If it throws a
new exception which is allowed by the exception specification which previously
was violated, then the
search for another handler will continue at the call of the function whose
exception specification was vio-
lated.
*/
void shutdown() {
static const char *s = "shutdown";
throw s;
}
typedef void(*PFV)();
int main (int argc, char *argv[]) {
PFV prev_fn = std::set_unexpected(&shutdown);
goo();
boo(); // should not reach here
return 0;
}
--
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/20131214/d5c02d3f/attachment.html>
More information about the llvm-bugs
mailing list