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: Thu, 14 Jul 2016 14:22:40 +0000
- Subject: [Bug c++/58796] throw nullptr not caught by catch(type*)
- Auto-submitted: auto-generated
- References: <bug-58796-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58796
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #12)
> (In reply to Jonathan Wakely from comment #4)
> > However with that patch the caught pointer is not null, so it's not right.
>
> For a pointer, you just need to set thrown_ptr to null.
Oh, well that's easier than I thought!
> For a pointer to member it's trickier, since they are thrown by reference,
> and we end up returning a pointer to the exception object. I suppose that
> since nullptr has no actual value we can feel free to clobber the "value" of
> the exception object before returning.
>
> For a pointer to member function that's still problematic because the
> exception object for 'throw nullptr' is currently one word, and a pointer to
> member function is two. So I suppose we will need to allocate two words for
> 'throw nullptr'. But clang doesn't do that; do they actually handle
> catching nullptr as a pointer to member function?
I don't know, when I test with clang it uses libstdc++.so, so the nullptr
doesn't get caught.