http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52099
Bug #: 52099
Summary: Incorrectly applying conversion when catching
pointer-to-members
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The follwing program shows that gcc erroneously matches an exception object of
a pointer-to-member type to a handler of (slightly) different type. There is
no allowance in 15.3 [except handle] to do that. In particular, adding a
cv-qualifier on top of the pointer-to-member type (which would be allowed)
cannot morph a pointer-to-nonconst-member function into a
pointer-to-const-member function.
#include <cassert>
struct A
{
void foo() {}
};
int main()
{
try
{
throw &A::foo;
}
catch (void (A::*)() const)
{
assert(false); // g++ currently takes this route
}
catch (...)
{
}
}