public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57720] New: [C++11]Crash when Delegating Constructors throw exceptions
@ 2013-06-26  7:17 liweifriends at gmail dot com
  2013-06-26  9:29 ` [Bug c++/57720] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: liweifriends at gmail dot com @ 2013-06-26  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57720
           Summary: [C++11]Crash when Delegating Constructors throw
                    exceptions
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liweifriends at gmail dot com

System type: 
    windows server 2012 + mingw-build (64 bit)

source code:

#include <iostream>
#include <stdexcept>
using namespace std;

class DCExcept
{
public:
    DCExcept(double d)
        try : DCExcept()
        {
            cout<<"Run the body."<<endl;
        }
        catch(...)
        {
            cout<<"Caught exception."<<endl;
        }

private:
    DCExcept()
    {
        throw runtime_error("error");
    }
};

int main()
{
    DCExcept a(1.2);
    return 0;
}


build cmd:
    g++.exe -Wall -fexceptions  -g  -std=c++11    -c d:\CPPLearn\main.cpp -o
obj\Debug\main.o
    g++.exe  -o bin\Debug\CPPLearn.exe obj\Debug\main.o 

run cmd: 
    CPPLearn.exe

compiler output:

Caught exception.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


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

* [Bug c++/57720] [C++11]Crash when Delegating Constructors throw exceptions
  2013-06-26  7:17 [Bug c++/57720] New: [C++11]Crash when Delegating Constructors throw exceptions liweifriends at gmail dot com
@ 2013-06-26  9:29 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2013-06-26  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This has nothing to do with delegating constructors, constructor try-blocks
cannot swallow exceptions, they are always rethrown at the end of the catch
block.  You get the same exception here:

    DCExcept(double d)
        try
        {
            cout<<"Run the body."<<endl;
            throw 1;
        }
        catch(...)
        {
            cout<<"Caught exception."<<endl;
        }


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

end of thread, other threads:[~2013-06-26  9:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26  7:17 [Bug c++/57720] New: [C++11]Crash when Delegating Constructors throw exceptions liweifriends at gmail dot com
2013-06-26  9:29 ` [Bug c++/57720] " 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).