This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/58796] throw nullptr not caught by catch(type*)


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'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]