public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/10606: uncaught_exception() returns false too early
@ 2003-05-02 21:26 sebor
  0 siblings, 0 replies; 2+ messages in thread
From: sebor @ 2003-05-02 21:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10606
>Category:       c++
>Synopsis:       uncaught_exception() returns false too early
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 02 21:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     sebor@roguewave.com
>Release:        3.2
>Organization:
>Environment:

>Description:
The program below shows that the gcc implementation of uncaught_exception() violates 15.5.3, p1. Specifically, the function is required to return true "until completing the initialization of the exception-declaration in the matching handler" which the gcc impletation fails to do (the output line marked <<<).

Martin
>How-To-Repeat:
$ cat t.cpp; g++ t.cpp && ./a.out 
#include <stdio.h>
#include <exception>

int main ()
{
#define SHOW(fun)   \
    printf ("%s(%d): %s: uncaught_exception() = %d\n", \
            __FILE__, __LINE__, fun, std::uncaught_exception ())

    struct S {
        S () { SHOW ("S::S()"); }
        S (const S &s) { SHOW ("S::S(const S&)"); }
        ~S () { SHOW ("S::~S()"); }
    };
    try {
        S s;

        throw s;
    }
    catch (S s) {
        SHOW ("catch");
    }
}
t.cpp(11): S::S(): uncaught_exception() = 0
t.cpp(12): S::S(const S&): uncaught_exception() = 0
t.cpp(13): S::~S(): uncaught_exception() = 1
t.cpp(12): S::S(const S&): uncaught_exception() = 0 <<<
t.cpp(21): catch: uncaught_exception() = 0
t.cpp(13): S::~S(): uncaught_exception() = 0
t.cpp(13): S::~S(): uncaught_exception() = 0
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/10606: uncaught_exception() returns false too early
@ 2003-05-02 22:36 Martin Sebor
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Sebor @ 2003-05-02 22:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/10606; it has been noted by GNATS.

From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/10606: uncaught_exception() returns false too early
Date: Fri, 02 May 2003 16:34:42 -0600

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10606
 
 Here's another test case that also shows that the function
 fails to return true after the exception has been rethrown:
 
 $ cat t.cpp; g++ t.cpp && ./a.out
 #include <stdio.h>
 #include <exception>
 
 void foo (const void*);
 
 int main ()
 {
 #define SHOW(fun)   \
      printf ("%s(%d): %s: uncaught_exception() = %d\n", \
              __FILE__, __LINE__, fun, std::uncaught_exception ())
 
      static int n;
 
      struct S {
          int id;
          S (): id (n++) {
              printf ("S::S() [%d]: uncaught_exception() = %d\n",
                      id, std::uncaught_exception ());
          }
          S (const S &s): id (n++) {
              printf ("S::S(const S& [%d]) [%d]: uncaught_exception() = 
 %d\n",
                      s.id, id, std::uncaught_exception ());
          }
          ~S () {
              printf ("S::~S() [%d]: uncaught_exception() = %d\n",
                      id, std::uncaught_exception ());
          }
      };
      try {
          try {
              S s;
              SHOW ("throw");
              throw s;
          }
          catch (S s) {
              SHOW ("catch");
              foo (&s);
              throw;
          }
      }
      catch (S s) {
          SHOW ("catch");
          foo (&s);
      }
 }
 
 void foo (const void*) { }
 S::S() [0]: uncaught_exception() = 0
 t.cpp(32): throw: uncaught_exception() = 0
 S::S(const S& [0]) [1]: uncaught_exception() = 0
 S::~S() [0]: uncaught_exception() = 1
 S::S(const S& [1]) [2]: uncaught_exception() = 0
 t.cpp(36): catch: uncaught_exception() = 0
 S::~S() [2]: uncaught_exception() = 0
 S::S(const S& [1]) [3]: uncaught_exception() = 0
 t.cpp(42): catch: uncaught_exception() = 0
 S::~S() [3]: uncaught_exception() = 0
 S::~S() [1]: uncaught_exception() = 0
 


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

end of thread, other threads:[~2003-05-02 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02 21:26 c++/10606: uncaught_exception() returns false too early sebor
2003-05-02 22:36 Martin Sebor

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).