Language
C++
Compiler
gcc 5.4.0
Options
Warnings
Boost 1.64.0
C++1z(GNU)
Boost 1.64.0
C++1z(GNU)
Boost 1.64.0
C++1z(GNU)
Boost 1.64.0
C++1z(GNU)
no pedantic
Raw runtime options
0 0 0 2
#include <iostream>
struct Base
{
virtual char const* what()
{
return "Base";
}
};
struct Derived : public Base
{
virtual char const* what()
{
return "Derived";
}
};
int main()
{
try
{
#if 0
throw Base();
#else
throw Derived();
#endif
}
#if 0
catch(Derived& e)
{
std::cout << "catch(Derived&) : " << e.what() << "\n";
}
#endif
catch(Base& e)
{
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.64.0/gcc-5.4.0/include -std=gnu++1z
catch(Base&) : Derived
Exit Code:
0