From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13491 invoked by alias); 28 Dec 2002 03:56:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 13472 invoked by uid 71); 28 Dec 2002 03:56:01 -0000 Resent-Date: 28 Dec 2002 03:56:01 -0000 Resent-Message-ID: <20021228035601.13471.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, sunil.k.davasam@intel.com Received: (qmail 6090 invoked by uid 61); 28 Dec 2002 03:46:33 -0000 Message-Id: <20021228034633.6084.qmail@sources.redhat.com> Date: Fri, 27 Dec 2002 19:56:00 -0000 From: sunil.k.davasam@intel.com Reply-To: sunil.k.davasam@intel.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9075: Destructor is called more times than required.. X-SW-Source: 2002-12/txt/msg01331.txt.bz2 List-Id: >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 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 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; }