public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8563: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling.
@ 2002-11-20  0:06 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-11-20  0:06 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, sunil.k.davasam

Synopsis: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling.

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Nov 13 11:23:18 2002
State-Changed-Why:
    This is already fixed on mainline (what is to become gcc3.3).
    Confirmed for gcc2.95...3.2.1.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8563


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

* c++/8563: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling.
@ 2002-11-19 19:06 sunil.k.davasam
  0 siblings, 0 replies; 2+ messages in thread
From: sunil.k.davasam @ 2002-11-19 19:06 UTC (permalink / raw)
  To: gcc-gnats; +Cc: sunil.k.davasam


>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;
}


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

end of thread, other threads:[~2002-11-13 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-20  0:06 c++/8563: C++ Standard Issue ( 15.2.2 violation ) : Base class destructor is not called during exception handling bangerth
  -- strict thread matches above, loose matches on Subject: below --
2002-11-19 19:06 sunil.k.davasam

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