if (is_equal(__pointee, thrown_pointer_type->__pointee, false))
return true;
// bullet 3A
- if (is_equal(__pointee, &typeid(void), false))
- return true;
-
+ if (is_equal(__pointee, &typeid(void), false)) {
+ // pointers to functions cannot be converted to void*.
+ // pointers to member functions are not handled here.
+ const __function_type_info* thrown_function =
+ dynamic_cast<const __function_type_info*>(thrown_pointer_type->__pointee);
+ return (thrown_function == nullptr);
+ }
// Handle pointer to pointer
const __pointer_type_info* nested_pointer_type =
dynamic_cast<const __pointer_type_info*>(__pointee);
#include <cassert>
+template <class Tp>
+bool can_convert(Tp) { return true; }
+
+template <class>
+bool can_convert(...) { return false; }
+
void f() {}
int main()
{
typedef void Function();
+ assert(!can_convert<Function&>(&f));
+ assert(!can_convert<void*>(&f));
try
{
throw f; // converts to void (*)()
{
assert(false);
}
+ catch (void*) // can't catch as void*
+ {
+ assert(false);
+ }
+ catch(Function*)
+ {
+ }
catch (...)
{
+ assert(false);
}
}