public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: sunil.k.davasam@intel.com To: gcc-gnats@gcc.gnu.org Subject: c++/9075: Destructor is called more times than required.. Date: Fri, 27 Dec 2002 19:56:00 -0000 [thread overview] Message-ID: <20021228034633.6084.qmail@sources.redhat.com> (raw) >Number: 9075 >Category: c++ >Synopsis: Destructor is called more times than required.. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Dec 27 19:56:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: sunil.k.davasam@intel.com >Release: g++3.2 >Organization: >Environment: $ g++ -v Reading specs from /local/skdavasa/gcc321/lib/gcc-lib/i386-redhat-linux/3.2.1/specs Configured with: gcc-3.2.1/configure --prefix=/local/skdavasa/gcc321 --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2.1 $ cat /etc/issue Red Hat Linux release 8.0 (Psyche) Kernel \r on an \m >Description: I have a small testcase. [skdavasa@yeti testing]$ cat t1.cpp #include <stdio.h> class C { public: C() { printf("C()\n"); } ~C() { printf("~C()\n"); } }; void func(C c) { printf("func()\n"); } int main(void) { C c; func(c); printf("main()\n"); return 0; } When I compiled and ran the above the test case, I found that destructor is called twice, where as constructor is called only once. I think it is wrong. >How-To-Repeat: $ g++ t1.cpp $ a.out C() func() ~C() main() ~C() --- Where as expected output: ------ C() func() main() ~C() -------- >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="t1.cpp" Content-Disposition: inline; filename="t1.cpp" #include <stdio.h> class C { public: C() { printf("C()\n"); } ~C() { printf("~C()\n"); } }; void func(C c) { printf("func()\n"); } int main(void) { C c; func(c); printf("main()\n"); return 0; }
next reply other threads:[~2002-12-28 3:56 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-27 19:56 sunil.k.davasam [this message] 2002-12-27 20:26 Andrew Pinski 2002-12-29 10:16 lerdsuwa
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=20021228034633.6084.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: 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).