This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58796] throw nullptr not caught by catch(type*)
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 13 Dec 2014 03:46:27 +0000
- Subject: [Bug c++/58796] throw nullptr not caught by catch(type*)
- Auto-submitted: auto-generated
- References: <bug-58796-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58796
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Target Milestone|--- |5.0
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
--- a/libstdc++-v3/libsupc++/eh_personality.cc
+++ b/libstdc++-v3/libsupc++/eh_personality.cc
@@ -230,6 +230,13 @@ get_adjusted_ptr (const std::type_info *catch_type,
*thrown_ptr_p = thrown_ptr;
return true;
}
+ if (throw_type == &typeid(nullptr))
+ {
+ if (catch_type->__is_pointer_p())
+ return true;
+ if (dynamic_cast<const __pointer_to_member_type_info*>(catch_type))
+ return true;
+ }
return false;
}
With that patch (which requires building eh_personality.cc with -std=gnu++11) I
get:
About to 'throw nullptr' (first case)
Caught 'throw nullptr' as type 'int A::*PointerToMember'
About to 'throw nullptr' (second case)
Caught 'throw nullptr' as type 'void *'
About to 'throw nullptr' (last case)
Caught 'throw nullptr' as type 'int A::*PointerToMember'