public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: sunil.k.davasam@intel.com
To: gcc-gnats@gcc.gnu.org
Cc: sunil.k.davasam@intel.com
Subject: c++/8563: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling.
Date: Tue, 19 Nov 2002 19:06:00 -0000	[thread overview]
Message-ID: <20021113191525.23117.qmail@sources.redhat.com> (raw)


>Number:         8563
>Category:       c++
>Synopsis:       C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 13 11:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     sunil.k.davasam@intel.com
>Release:        gcc-3.2
>Organization:
>Environment:
I tried on IA32 Redhat8.0 product, with gcc3.2 compiler.
>Description:
This testcase has a exception in derived class destructor, there is no catch inside destructor. There is a matching catch in main(). This is to check  whether the base class destructor is called during exception handling.

-------------------------t2.cpp........................
#include <stdio.h>
struct C1
{
        virtual int f9()        { return 1; }
        C1() { printf("C1()\n" ); }
        ~C1() { printf("~C1()\n" ); }
};

struct C2 : public C1 {
        C2() { printf("C2()\n" ); }
        ~C2() { printf("~C2()\n" );  throw 1; }
};


int main()
{
        try {
                C2 o2;
        } catch ( C1 o1 ) {
                printf("Catching C%d exception.\n",1 );
        } catch ( int i ) {
                printf("Catching int exception.\n" );
        }
        return 0;
}

----------------------------------------------
Expected output:
------------
C1()
C2()
~C2()
~C1()
Catching int exception.
-------------
Actual output:
--------
C1()
C2()
~C2()
Catching int exception.
--------

Based on C++ Standard  ( except.ctor  ) 15.2.2:

An object that is partially constructed or partially destroyed will have destructors executed for all of its fully constructed subobjects, that is, for subobjects for which the constructor has completed execution and the destructor has not yet begun execution.
-------

>How-To-Repeat:
[skdavasa@csattert1 failed_testcases]$ g++ t2.cpp
[skdavasa@csattert1 failed_testcases]$ a.out
C1()
C2()
~C2()
Catching int exception.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="t3.cpp"
Content-Disposition: inline; filename="t3.cpp"

#include <stdio.h>
struct C1
{
	virtual int f9()	{ return 1; }
	C1() { printf("C1()\n" ); }
	~C1() { printf("~C1()\n" ); }
};

struct C2 : public C1 {
	C2() { printf("C2()\n" ); }
	~C2() { printf("~C2()\n" );  throw 1; }
};


int main()
{
	try {
		C2 o2;
	} catch ( C1 o1 ) {
		printf("Catching C%d exception.\n",1 );
	} catch ( int i ) {
		printf("Catching int exception.\n" );
	}
	return 0;
}


             reply	other threads:[~2002-11-13 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-19 19:06 sunil.k.davasam [this message]
2002-11-20  0:06 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021113191525.23117.qmail@sources.redhat.com \
    --to=sunil.k.davasam@intel.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).