public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: kristian.spangsege@framfab.dk To: gcc-gnats@gcc.gnu.org Cc: brian.kristiansen@oracle.com Subject: c++/8287: GCC3.2: Destructor called for non-constructed local object Date: Sat, 19 Oct 2002 12:16:00 -0000 [thread overview] Message-ID: <20021019190958.23749.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-10-19 19:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-10-19 12:16 kristian.spangsege [this message] 2002-10-28 16:16 Kristian Spangsege 2002-10-28 16:19 bangerth 2002-10-29 16:07 mmitchel
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=20021019190958.23749.qmail@sources.redhat.com \ --to=kristian.spangsege@framfab.dk \ --cc=brian.kristiansen@oracle.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: linkBe 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).