https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62154
Bug ID: 62154 Summary: std::throw_with_nested should not require a polymorphic type Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jaak at ristioja dot ee #include <exception> struct E { E(int) {} }; int main() { std::throw_with_nested(E(42)); return 0; } Compiling with "g++ -std=c++11 -Wall -Wextra". Tried with GCC 4.7.4, 4.8.3 and 4.9.1 and Clang. In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/exception:163:0, from test.cpp:1: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/bits/nested_exception.h: In instantiation of 'static const std::nested_exception* std::__get_nested_helper<_Ex>::_S_get(const _Ex&) [with _Ex = E]': /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/bits/nested_exception.h:104:51: required from 'const std::nested_exception* std::__get_nested_exception(const _Ex&) [with _Ex = E]' /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/bits/nested_exception.h:138:38: required from 'void std::throw_with_nested(_Ex) [with _Ex = E]' test.cpp:6:31: required from here /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.1/include/g++-v4/bits/nested_exception.h:90:59: error: cannot dynamic_cast '& __ex' (of type 'const struct E*') to type 'const class std::nested_exception*' (source type is not polymorphic) { return dynamic_cast<const nested_exception*>(&__ex); } ^