public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58796] New: throw nullptr not caught by catch(type*)
@ 2013-10-18 20:03 seurer at us dot ibm.com
  2013-10-30 14:39 ` [Bug c++/58796] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: seurer at us dot ibm.com @ 2013-10-18 20:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58796

            Bug ID: 58796
           Summary: throw nullptr not caught by catch(type*)
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: seurer at us dot ibm.com

C++ standard section 15.3
A handler is a match for an exception object of type E if
...
— the handler is of type cv T or const T& where T is a pointer or pointer to
member type and E is std::nullptr_t.

A catch handler of a pointer type (the "T" in the quote from the standard)
should catch a throw of nullptr (the E). This is different than, say, "throw 7"
which will only be caught by something like an int catch (7 being an int) and
not a long catch.

However, when you try this with gcc it doesn't work.  Only a catch with
nullptr_t will catch throws of nullptr; catches with other pointer types that
should catch it don't.  

Note that this may instead be an issue with the library.

This is the output I get from the program that follows:

About to 'throw nullptr' (first case)
Didn't catch 'throw nullptr' at all
About to 'throw nullptr' (second case)
Didn't catch 'throw nullptr' at all
About to 'throw nullptr' (last case)
Caught 'throw nullptr' as type 'std::nullptr_t'


#include <iostream>
#include <cstddef>

struct A {};
typedef int A::*PointerToMember;

int main() {
   try {
      try {
         std::cout << "About to 'throw nullptr' (first case)" << std::endl;
         throw nullptr;
      } catch (PointerToMember) { // This *should* catch throw nullptr...
         std::cout << "Caught 'throw nullptr' as type 'int
A::*PointerToMember'" << std::endl;
      }
   } catch (...) {
      std::cout << "Didn't catch 'throw nullptr' at all" << std::endl;
   }

   try {
      try {
         std::cout << "About to 'throw nullptr' (second case)" << std::endl;
         throw nullptr;
      } catch(void *) { // This *should* catch throw nullptr...
         std::cout << "Caught 'throw nullptr' as type 'void *'" << std::endl;
      }
   } catch (...) {
      std::cout << "Didn't catch 'throw nullptr' at all" << std::endl;
   }

   try {
      try {
         std::cout << "About to 'throw nullptr' (last case)" << std::endl;
         throw nullptr;
      } catch (PointerToMember) {
         std::cout << "Caught 'throw nullptr' as type 'int
A::*PointerToMember'" << std::endl;
      } catch(void *) {
         std::cout << "Caught 'throw nullptr' as type 'void *'" << std::endl;
      } catch(std::nullptr_t) {
         std::cout << "Caught 'throw nullptr' as type 'std::nullptr_t'" <<
std::endl;
      }
   } catch (...) {
      std::cout << "Didn't catch 'throw nullptr' at all" << std::endl;
   }

   return 0;
}
>From gcc-bugs-return-432162-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 18 20:29:26 2013
Return-Path: <gcc-bugs-return-432162-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20416 invoked by alias); 18 Oct 2013 20:29:25 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20370 invoked by uid 48); 18 Oct 2013 20:29:22 -0000
From: "jsm28 at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/58797] New: Expand __builtin_copysignl inline for powerpc soft-float/e500v1
Date: Fri, 18 Oct 2013 20:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jsm28 at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cf_gcctarget
Message-ID: <bug-58797-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01306.txt.bz2
Content-length: 841

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX797

            Bug ID: 58797
           Summary: Expand __builtin_copysignl inline for powerpc
                    soft-float/e500v1
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsm28 at gcc dot gnu.org
            Target: powerpc*-*-linux*

The powerpc port should have an insn pattern for copysigntf3 for soft-float and
e500v1; right now, the complex multiplication/division in libgcc ends up with
an undefined reference to copysignl in those configurations.  This doesn't
generally cause problems for glibc users - glibc has copysignl in libc as well
as libm - but can trip up users of other C libraries.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-16  9:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 20:03 [Bug c++/58796] New: throw nullptr not caught by catch(type*) seurer at us dot ibm.com
2013-10-30 14:39 ` [Bug c++/58796] " redi at gcc dot gnu.org
2014-12-12 10:47 ` paolo.carlini at oracle dot com
2014-12-13  3:46 ` redi at gcc dot gnu.org
2014-12-15 13:59 ` redi at gcc dot gnu.org
2015-04-22 12:01 ` jakub at gcc dot gnu.org
2015-07-16  9:20 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).