public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception.
@ 2013-11-21  2:48 man2gm at gmail dot com
  2013-11-21 14:02 ` [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: man2gm at gmail dot com @ 2013-11-21  2:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59224
           Summary: std::uncaught_exception always returns true after
                    exception while constructing another exception.
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: man2gm at gmail dot com

This code prints (erroneously)

Hello, world!
1

in g++ 4.8.1, g++ 4.6.3, but works correctly in g++ 4.5.2.

cat main.cpp 
#include <string>
#include <iostream>


struct Exception
{
        std::string what;
        Exception(const std::string & what_) : what(what_) {}
};


std::string f()
{
        throw Exception("Hello, world!");
}

void g()
{
        try
        {
                f();
        }
        catch (...)
        {
                throw Exception(f());
        }
}


int main(int argc, char ** argv)
{
        try
        {
                g();
        }
        catch (const Exception & e)
        {
                std::cerr << e.what << std::endl;
        }

        /// returns 1 in gcc 4.6.3, 4.8.1 - bug
        std::cerr << std::uncaught_exception() << std::endl;

        return 0;
}


# g++-4.8 --version
g++-4.8 (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
Copyright (C) 2013 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.

# g++-4.8 main.cpp
# ./a.out 
Hello, world!
1

# g++-4.6 --version
g++-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 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.

# g++-4.6 main.cpp
# ./a.out 
Hello, world!
1

# g++-4.5 --version
g++-4.5 (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 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.

# g++-4.5 main.cpp
# ./a.out 
Hello, world!
0


http://ideone.com/lx2ao2


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
@ 2013-11-21 14:02 ` redi at gcc dot gnu.org
  2013-11-21 14:11 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-21 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-21
      Known to work|                            |4.5.1
            Summary|std::uncaught_exception     |[4.7/4.8/4.9 Regression]
                   |always returns true after   |std::uncaught_exception
                   |exception while             |returns true while
                   |constructing another        |constructing exception.
                   |exception.                  |
     Ever confirmed|0                           |1
      Known to fail|                            |4.6.0, 4.7.4, 4.8.2, 4.9.0

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. uncaught_exception becomes true while evaluating the operand of the
throw statement, but should only be true after initialization of the exception
object is complete.

#include <exception>

int f()
{
  if (std::uncaught_exception())
    std::terminate();
  return 1;
}

int main()
{
  try
  {
    throw f();
  }
  catch (...)
  {
  }
}


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
  2013-11-21 14:02 ` [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception redi at gcc dot gnu.org
@ 2013-11-21 14:11 ` redi at gcc dot gnu.org
  2013-12-19 15:20 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-21 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Possibly a dup of PR 41174 (although that was wrong prior to 4.6.0)


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
  2013-11-21 14:02 ` [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception redi at gcc dot gnu.org
  2013-11-21 14:11 ` redi at gcc dot gnu.org
@ 2013-12-19 15:20 ` rguenth at gcc dot gnu.org
  2013-12-19 15:34 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-12-19 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.4


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (2 preceding siblings ...)
  2013-12-19 15:20 ` rguenth at gcc dot gnu.org
@ 2013-12-19 15:34 ` rguenth at gcc dot gnu.org
  2014-01-24 19:07 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-12-19 15:34 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (3 preceding siblings ...)
  2013-12-19 15:34 ` rguenth at gcc dot gnu.org
@ 2014-01-24 19:07 ` jason at gcc dot gnu.org
  2014-01-27 13:58 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-24 19:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-24 19:07 ` jason at gcc dot gnu.org
@ 2014-01-27 13:58 ` jason at gcc dot gnu.org
  2014-01-27 13:59 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Mon Jan 27 13:57:39 2014
New Revision: 207129

URL: http://gcc.gnu.org/viewcvs?rev=207129&root=gcc&view=rev
Log:
    Core DR 475
    PR c++/41174
    PR c++/59224
    * libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions.
    * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception)
    (__cxa_allocate_exception): Don't set it here.

Added:
    trunk/gcc/testsuite/g++.dg/eh/uncaught4.C
Modified:
    trunk/gcc/testsuite/g++.dg/eh/uncaught1.C
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/libsupc++/eh_alloc.cc
    trunk/libstdc++-v3/libsupc++/eh_throw.cc


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-27 13:58 ` jason at gcc dot gnu.org
@ 2014-01-27 13:59 ` jason at gcc dot gnu.org
  2014-01-27 14:03 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Mon Jan 27 13:58:48 2014
New Revision: 207131

URL: http://gcc.gnu.org/viewcvs?rev=207131&root=gcc&view=rev
Log:
    Core DR 475
    PR c++/41174
    PR c++/59224
    * libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions.
    * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception)
    (__cxa_allocate_exception): Don't set it here.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/eh/uncaught4.C
Modified:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/eh/uncaught1.C
    branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_8-branch/libstdc++-v3/libsupc++/eh_alloc.cc
    branches/gcc-4_8-branch/libstdc++-v3/libsupc++/eh_throw.cc


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (7 preceding siblings ...)
  2014-01-27 14:03 ` jason at gcc dot gnu.org
@ 2014-01-27 14:03 ` jason at gcc dot gnu.org
  2014-04-01 17:29 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

Bug 59224 depends on bug 41174, which changed state.

Bug 41174 Summary: uncaught_exception always returns true
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41174

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (6 preceding siblings ...)
  2014-01-27 13:59 ` jason at gcc dot gnu.org
@ 2014-01-27 14:03 ` jason at gcc dot gnu.org
  2014-01-27 14:03 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.8.3

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.8.3/4.9.  Not fixing on 4.7 branch.


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (8 preceding siblings ...)
  2014-01-27 14:03 ` jason at gcc dot gnu.org
@ 2014-04-01 17:29 ` jason at gcc dot gnu.org
  2014-04-01 17:30 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-04-01 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Apr  1 17:28:29 2014
New Revision: 208991

URL: http://gcc.gnu.org/viewcvs?rev=208991&root=gcc&view=rev
Log:
    Core DR 475
    PR c++/41174
    PR c++/59224
    * libsupc++/eh_throw.cc (__cxa_throw): Set uncaughtExceptions.
    * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception)
    (__cxa_allocate_exception): Don't set it here.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/eh/uncaught4.C
Modified:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/eh/uncaught1.C
    branches/gcc-4_7-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_7-branch/libstdc++-v3/libsupc++/eh_alloc.cc
    branches/gcc-4_7-branch/libstdc++-v3/libsupc++/eh_throw.cc


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (9 preceding siblings ...)
  2014-04-01 17:29 ` jason at gcc dot gnu.org
@ 2014-04-01 17:30 ` jason at gcc dot gnu.org
  2015-05-12  8:13 ` lixin.fnst at cn dot fujitsu.com
  2015-05-12 10:55 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2014-04-01 17:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.3                       |4.7.4

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
OK, fixed for 4.7.4 as well.


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (10 preceding siblings ...)
  2014-04-01 17:30 ` jason at gcc dot gnu.org
@ 2015-05-12  8:13 ` lixin.fnst at cn dot fujitsu.com
  2015-05-12 10:55 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: lixin.fnst at cn dot fujitsu.com @ 2015-05-12  8:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59224

li xin <lixin.fnst at cn dot fujitsu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lixin.fnst at cn dot fujitsu.com

--- Comment #8 from li xin <lixin.fnst at cn dot fujitsu.com> ---
(In reply to Jason Merrill from comment #5)
> Fixed for 4.8.3/4.9.  Not fixing on 4.7 branch.

It will lead to the lsb test caes
/libstdcxx-t2c/tests/LanguageSupport/LanguageSupport FAIL.
So I want to know the right return value of std::uncaught_exception() (inside
exception-constructor).

The LSB test code is as follows:

cat main.cpp
#include <string.h>
#include <iostream>

using namespace std;
class exception_test : public exception
{
        public:
                bool result;
                exception_test(): exception(){result = uncaught_exception();}
                ~exception_test() throw(){};
};

int main(int argc, char ** argv)
{
        bool result;

        try
        {
                throw exception_test();
        }
        catch(exception_test et)
        {
                result = et.result;
        }
        cerr << result << endl;
        return 0;
}

# g++ ./main.cpp
# ./a.out
0

My GCC version is 4.9.2, the return value of result is 0,and the test is FAIL.
If the the return value of result is 1,and the test will be PASS.


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

* [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception.
  2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
                   ` (11 preceding siblings ...)
  2015-05-12  8:13 ` lixin.fnst at cn dot fujitsu.com
@ 2015-05-12 10:55 ` redi at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2015-05-12 10:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59224

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to li xin from comment #8)
> It will lead to the lsb test caes
> /libstdcxx-t2c/tests/LanguageSupport/LanguageSupport FAIL.
> So I want to know the right return value of std::uncaught_exception()
> (inside exception-constructor).

What isn't clear about the bug report? The right value is the one G++ gives
now.

The LSB test is wrong.


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

end of thread, other threads:[~2015-05-12 10:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-21  2:48 [Bug c++/59224] New: std::uncaught_exception always returns true after exception while constructing another exception man2gm at gmail dot com
2013-11-21 14:02 ` [Bug c++/59224] [4.7/4.8/4.9 Regression] std::uncaught_exception returns true while constructing exception redi at gcc dot gnu.org
2013-11-21 14:11 ` redi at gcc dot gnu.org
2013-12-19 15:20 ` rguenth at gcc dot gnu.org
2013-12-19 15:34 ` rguenth at gcc dot gnu.org
2014-01-24 19:07 ` jason at gcc dot gnu.org
2014-01-27 13:58 ` jason at gcc dot gnu.org
2014-01-27 13:59 ` jason at gcc dot gnu.org
2014-01-27 14:03 ` jason at gcc dot gnu.org
2014-01-27 14:03 ` jason at gcc dot gnu.org
2014-04-01 17:29 ` jason at gcc dot gnu.org
2014-04-01 17:30 ` jason at gcc dot gnu.org
2015-05-12  8:13 ` lixin.fnst at cn dot fujitsu.com
2015-05-12 10:55 ` redi 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).