public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8287: GCC3.2: Destructor called for non-constructed local object
@ 2002-10-19 12:16 kristian.spangsege
  0 siblings, 0 replies; 4+ messages in thread
From: kristian.spangsege @ 2002-10-19 12:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: brian.kristiansen


>Number:         8287
>Category:       c++
>Synopsis:       GCC3.2: Destructor called for non-constructed local object
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 19 12:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Kristian Spangsege
>Release:        gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Organization:
>Environment:
RedHat 8.0 (Full install) on dual Intel Pentium III
And various other hardware configs. with RedHat 8.0
>Description:
In the "top-level" scope of a destructor for some class B a local object of class A will have its destructor called even if it was never initialized by its constructor due to a return statement appearing before the declaration of the local object.

The problem does not occur if the local object and the earlier return statement is placed in and ordinary method. Also the problem disappears if the entire destructor body of B is put within an otherwise redundant scope, similarly if only the declaration of the local object is put into a new scope.

The problem also does not occur with GCC-2.96.

The problem obviously results in core dumps unless one of the mentioned work-arounds are applied. But this is close to impossible when porting large applications from earlier versions of gcc.

(I'm utterly amazed about the fact that RedHad has managed to release its RedHat 8.0 entirely base on gcc3.2, when gcc3.2 has susch a lethal bug within it)

Btw. it took me 3 days of reducing 50000 lines of code to around 20 before I was even close to realizing what the bug was.

Go fix it :-)
>How-To-Repeat:
$ g++ test.C
$ ./a.out

And "test.C" is:

#include <iostream>

struct A
{
  A()  { std::cerr << "c\n"; }
  ~A() { std::cerr << "d\n"; }
};

struct B
{
  ~B()
  {
    if(true) return;
    A a;
  }
};

int main()
{
  B b;
  return 0;
}
>Fix:
Apply one of the work-arounds mentioned in "Description".
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/8287: GCC3.2: Destructor called for non-constructed local object
@ 2002-10-29 16:07 mmitchel
  0 siblings, 0 replies; 4+ messages in thread
From: mmitchel @ 2002-10-29 16:07 UTC (permalink / raw)
  To: brian.kristiansen, gcc-bugs, gcc-prs, kristian.spangsege, nobody

Synopsis: GCC3.2: Destructor called for non-constructed local object

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Tue Oct 29 16:07:54 2002
State-Changed-Why:
    Fixed in GCC 3.2.1.

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


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

* Re: c++/8287: GCC3.2: Destructor called for non-constructed local object
@ 2002-10-28 16:19 bangerth
  0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2002-10-28 16:19 UTC (permalink / raw)
  To: brian.kristiansen, gcc-bugs, gcc-prs, kristian.spangsege, nobody

Synopsis: GCC3.2: Destructor called for non-constructed local object

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Oct 28 16:19:29 2002
State-Changed-Why:
    Confirmed with bot 3.2.1pre and CVS. This seems to me like
    a _very_ serious regression, so I raise the priority.
    
    B.t.w.: the problem has nothing to do with copy constructors,
    which usually seem to be the problem in these kind of
    reports.

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


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

* Re: c++/8287: GCC3.2: Destructor called for non-constructed local object
@ 2002-10-28 16:16 Kristian Spangsege
  0 siblings, 0 replies; 4+ messages in thread
From: Kristian Spangsege @ 2002-10-28 16:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Kristian Spangsege <kristian.spangsege@framfab.dk>
To: brian.kristiansen@oracle.com, gcc-gnats@gcc.gnu.org,
	gcc-prs@gcc.gnu.org, kristian.spangsege@framfab.dk,
	gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/8287: GCC3.2: Destructor called for non-constructed local
 object
Date: Tue, 29 Oct 2002 01:09:21 +0100

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


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

end of thread, other threads:[~2002-10-30  0:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-19 12:16 c++/8287: GCC3.2: Destructor called for non-constructed local object kristian.spangsege
2002-10-28 16:16 Kristian Spangsege
2002-10-28 16:19 bangerth
2002-10-29 16:07 mmitchel

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