public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/4250: destructor is not called during stack unwinding after exception
@ 2001-09-10 10:46 Michal Furmanczyk
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Furmanczyk @ 2001-09-10 10:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4250; it has been noted by GNATS.

From: "Michal Furmanczyk" <mf@cfdrc.com>
To: <rodrigc@gcc.gnu.org>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>,
        <nobody@gcc.gnu.org>
Subject: Re: c++/4250: destructor is not called during stack unwinding after exception
Date: Mon, 10 Sep 2001 12:41:59 -0500

 Hi,
 
 Finally I managed to find space on my computer and installed GCC 3.0.1.
 The new version of compiler work fine, the problem not longer exists!!!
 
 Anyway, I put the complete test.cpp file below.
 I recompiled some of our programs with new compiler and
 I'm impressed with speed improvement I received (compared to egcs).
 You guys made the excellent job.
 
 I would like to signal one problem with your GCC bug reporting web page.
 It states that it is possible to make Online Test Compilation with last
 night's snapshot at Code Sourcery.
 I tried it, before I sent bug report (additionally to tests I performed on
 my own computer with GCC 3.0)
 and the binary generated from this web site fail to pass this test. So now I
 am confused.
 I suppose that the compiler used by Code Sourcery is old and suggestion form
 web page
 http://www.gnu.org/software/gcc/bugs.html#report to use it for tests of
 current compiler is misleading.
 
 Michal
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4250&database=gcc
 
 The test.cpp file:
 
 #include <iostream>
 #include <stdexcept>
 
 class Test {
 public:
   Test() { std::cerr << "ctor called" << std::endl; }
   ~Test() { std::cerr << "dtor called" << std::endl; }
 };
 
 void e() {
   // it can throw anything
   throw std::logic_error("test");
 }
 
 void f() {
   Test t;
   try {
     e();
   }
   catch(std::runtime_error&) {
   // this should not catch exception from e function
   // if exception is catch at the first try-catch block
   // containing throw point code generated by GCC work correctly
   }
 }
 
 int main() {
   try {
     f();
   }
   catch(std::exception&) {
   // exception is catch here, outside of f function
   // it means t should be already destroyed
   }
   return 0;
 }
 
 


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

* Re: c++/4250: destructor is not called during stack unwinding after exception
@ 2001-09-10 12:35 rodrigc
  0 siblings, 0 replies; 4+ messages in thread
From: rodrigc @ 2001-09-10 12:35 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mf, nobody, rodrigc

Synopsis: destructor is not called during stack unwinding after exception

State-Changed-From-To: feedback->closed
State-Changed-By: rodrigc
State-Changed-When: Mon Sep 10 12:35:21 2001
State-Changed-Why:
    Fixed in gcc 3.0.1.
    The CodeSourcery autocompile web page does have
    an outdated compiler, but the CodeSourcery guys
    have been very busy lately, and have not had
    time to update it.
    
    Send e-mail to webmaster@codesourcery.com to ask
    them about updating their autocompiler.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4250&database=gcc


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

* Re: c++/4250: destructor is not called during stack unwinding after exception
@ 2001-09-07 22:11 rodrigc
  0 siblings, 0 replies; 4+ messages in thread
From: rodrigc @ 2001-09-07 22:11 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mf, nobody, rodrigc

Synopsis: destructor is not called during stack unwinding after exception

State-Changed-From-To: open->feedback
State-Changed-By: rodrigc
State-Changed-When: Fri Sep  7 22:11:01 2001
State-Changed-Why:
    Your testcase is truncated.  Can you submit your
    testcase again?
    
    Also, can you verify that your problem still
    occurs with gcc 3.0.1?

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4250&database=gcc


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

* c++/4250: destructor is not called during stack unwinding after exception
@ 2001-09-06  9:46 mf
  0 siblings, 0 replies; 4+ messages in thread
From: mf @ 2001-09-06  9:46 UTC (permalink / raw)
  To: gcc-gnats

>Number:         4250
>Category:       c++
>Synopsis:       destructor is not called during stack unwinding after exception
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 06 09:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Michal Furmanczyk
>Release:        gcc 3.0 (build with --enable-threads)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
When there is a try-catch block in function, local variables located before this block and the exception is thrown in this block but not catch the destructors of local variables are not called. Exception is catch in another try-catch block outside the function, therefore after the point when local variables should be destroy.
>How-To-Repeat:
Compile this code with: g++ -o test test.cpp
The result program print only: ctor called
it should print: ctor called, dtor called
The same is with -O1 and -O2 option.

>Fix:

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

#include <iostream>
#include <stdexcept>

class Test {
public:
  Test() { std::cerr << "ctor called" << std::endl; }
  ~Test() { std::cerr << "dtor called" << std::endl; }
};

void e() {
  throw std::logic_error("test");
}

void f() {
  Test t;
  try {
    e();
  }  
  catch(std::runtime_error&) {
  }
}

int main() {
  try {
    f();
  }
  catch(std::exception&) {
  }
  return 0;
}


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

end of thread, other threads:[~2001-09-10 12:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-10 10:46 c++/4250: destructor is not called during stack unwinding after exception Michal Furmanczyk
  -- strict thread matches above, loose matches on Subject: below --
2001-09-10 12:35 rodrigc
2001-09-07 22:11 rodrigc
2001-09-06  9:46 mf

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