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

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