public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/37477]  New: std::uncaught_exception() returns wrong value after entering terminate() in some cases
@ 2008-09-11 10:12 tsyvarev at ispras dot ru
  2008-09-11 10:19 ` [Bug libstdc++/37477] " tsyvarev at ispras dot ru
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: tsyvarev at ispras dot ru @ 2008-09-11 10:12 UTC (permalink / raw)
  To: gcc-bugs

The description of uncaught_exception() throw() function states (18.6.4):

Returns: true after completing evaluation of a throw-expression until either
completing initialization of the exception-declaration in the matching handler
or entering unexpected() due to the throw; or after entering terminate() for
any reason other than an explicit call to terminate().

Apart from an explicit call to terminate() from the user's code, terminate() is
called in the following situations (15.5.1):

1. When the exception handling mechanism, after completing evaluation of the
expression to be thrown but before the exception is caught, calls a user
function that exits via an uncaught exception.
2. When the exception handling mechanism cannot find a handler for a thrown
exception.
3. When the destruction of an object during stack unwinding exits using an
exception.
4. When construction or destruction of a non-local object with static storage
duration exits using an exception.
5. When execution of a function registered with atexit exits using an
exception.
6. When a throw-expression with no operand attempts to rethrow an exception and
no exception is being handled.
7. When unexpected throws an exception which is not allowed by the previously
violated exception specification, and std::bad_exception is not included in
that exception-specification.

However std::uncaught_exception called within a terminate_handler returns false
in the cases 2,4,5,7 and true in the other cases (terminate_handler is
specified using std::set_terminate()).

The attached examples demonstrate the above 7 situations when terminate() is
called "implicitly" and display the return value of std::uncaught_exception().

For example, reproducing situation 2:

andrew@Ubuntu:/mnt/hgfs/shared/temp/test$ g++ -Wall test2.cpp && ./a.out
Exception will be thrown and it won't be catched.
This situation meets the following condition when terminate should be called:
2.When the exception handling mechanism cannot find a handler
for a thrown exception.
Inside terminate_handler uncaught_exception() returns *false*.
terminate called after throwing an instance of 'char const*'
Aborted (core dumped)
andrew@Ubuntu:/mnt/hgfs/shared/temp/test$ g++ --version
g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 
           Summary: std::uncaught_exception() returns wrong value after
                    entering terminate() in some cases
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tsyvarev at ispras dot ru


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


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

* [Bug libstdc++/37477] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
@ 2008-09-11 10:19 ` tsyvarev at ispras dot ru
  2008-09-11 10:31 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: tsyvarev at ispras dot ru @ 2008-09-11 10:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tsyvarev at ispras dot ru  2008-09-11 10:18 -------
Created an attachment (id=16292)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16292&action=view)
test.tar

Reproduce situations when terminate is called implicitly.


-- 


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


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

* [Bug libstdc++/37477] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
  2008-09-11 10:19 ` [Bug libstdc++/37477] " tsyvarev at ispras dot ru
@ 2008-09-11 10:31 ` paolo dot carlini at oracle dot com
  2009-07-07  0:58 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-09-11 10:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2008-09-11 10:29 -------
Note this is a libsupc++ issue, we don't have a specific Bugzilla component,
but as a matter of fact the code has been mostly implemented and maintained by
different people than the libstdc++ maintainers... I'm afraid it will take some
time to review the issue and in case work on the code.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at gcc dot gnu dot org


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


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

* [Bug libstdc++/37477] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
  2008-09-11 10:19 ` [Bug libstdc++/37477] " tsyvarev at ispras dot ru
  2008-09-11 10:31 ` paolo dot carlini at oracle dot com
@ 2009-07-07  0:58 ` paolo dot carlini at oracle dot com
  2010-01-08 19:12 ` [Bug libstdc++/37477] [Core 475] " paolo dot carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-07  0:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-07-07 00:58 -------
Richard, any chance you can look a bit into this? Many thanks in advance.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo dot carlini at oracle
                   |                            |dot com


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


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

* [Bug libstdc++/37477] [Core 475] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
                   ` (2 preceding siblings ...)
  2009-07-07  0:58 ` paolo dot carlini at oracle dot com
@ 2010-01-08 19:12 ` paolo dot carlini at oracle dot com
  2010-01-08 19:13 ` paolo dot carlini at oracle dot com
  2010-04-21 20:47 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-01-08 19:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2010-01-08 19:12 -------
I'm trusting Jon here: in the audi trail of PR41174 he mentioned that this
issue depends on the resolution of Core issue 475 (currently in drafting):

  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#475




-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-01-08 19:12:20
               date|                            |
            Summary|std::uncaught_exception()   |[Core 475]
                   |returns wrong value after   |std::uncaught_exception()
                   |entering terminate() in some|returns wrong value after
                   |cases                       |entering terminate() in some
                   |                            |cases


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


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

* [Bug libstdc++/37477] [Core 475] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
                   ` (3 preceding siblings ...)
  2010-01-08 19:12 ` [Bug libstdc++/37477] [Core 475] " paolo dot carlini at oracle dot com
@ 2010-01-08 19:13 ` paolo dot carlini at oracle dot com
  2010-04-21 20:47 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-01-08 19:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo dot carlini at oracle dot com  2010-01-08 19:12 -------
Suspending, waiting for [Ready].


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED


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


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

* [Bug libstdc++/37477] [Core 475] std::uncaught_exception() returns wrong value after entering terminate() in some cases
  2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
                   ` (4 preceding siblings ...)
  2010-01-08 19:13 ` paolo dot carlini at oracle dot com
@ 2010-04-21 20:47 ` paolo dot carlini at oracle dot com
  5 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-04-21 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2010-04-21 20:46 -------
The status is now [Ready], unsuspending.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |NEW
   Last reconfirmed|2010-01-08 19:12:20         |2010-04-21 20:46:01
               date|                            |


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


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

* [Bug libstdc++/37477] [Core 475] std::uncaught_exception() returns wrong value after entering terminate() in some cases
       [not found] <bug-37477-4@http.gcc.gnu.org/bugzilla/>
  2011-06-15 14:16 ` maxime at altribe dot org
@ 2011-06-15 14:18 ` maxime at altribe dot org
  1 sibling, 0 replies; 9+ messages in thread
From: maxime at altribe dot org @ 2011-06-15 14:18 UTC (permalink / raw)
  To: gcc-bugs

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

Maxime van Noppen <maxime at altribe dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxime at altribe dot org

--- Comment #8 from Maxime van Noppen <maxime at altribe dot org> 2011-06-15 14:16:38 UTC ---
I just attached a testcase which seems likely related to this bug. Tested with
g++ (GCC) 4.6.0 20110603 on x86_64 linux.


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

* [Bug libstdc++/37477] [Core 475] std::uncaught_exception() returns wrong value after entering terminate() in some cases
       [not found] <bug-37477-4@http.gcc.gnu.org/bugzilla/>
@ 2011-06-15 14:16 ` maxime at altribe dot org
  2011-06-15 14:18 ` maxime at altribe dot org
  1 sibling, 0 replies; 9+ messages in thread
From: maxime at altribe dot org @ 2011-06-15 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Maxime van Noppen <maxime at altribe dot org> 2011-06-15 14:15:38 UTC ---
Created attachment 24538
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24538
Exhibits uncaught return values


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

end of thread, other threads:[~2011-06-15 14:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-11 10:12 [Bug libstdc++/37477] New: std::uncaught_exception() returns wrong value after entering terminate() in some cases tsyvarev at ispras dot ru
2008-09-11 10:19 ` [Bug libstdc++/37477] " tsyvarev at ispras dot ru
2008-09-11 10:31 ` paolo dot carlini at oracle dot com
2009-07-07  0:58 ` paolo dot carlini at oracle dot com
2010-01-08 19:12 ` [Bug libstdc++/37477] [Core 475] " paolo dot carlini at oracle dot com
2010-01-08 19:13 ` paolo dot carlini at oracle dot com
2010-04-21 20:47 ` paolo dot carlini at oracle dot com
     [not found] <bug-37477-4@http.gcc.gnu.org/bugzilla/>
2011-06-15 14:16 ` maxime at altribe dot org
2011-06-15 14:18 ` maxime at altribe dot 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).