public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: plaflamme@konova.com To: gcc-gnats@gcc.gnu.org Cc: lletourneau@konova.com Subject: c++/7707: GCC 3.1.1 Optimization incomplete/incorrect : leaks temporary object Date: Fri, 23 Aug 2002 16:36:00 -0000 [thread overview] Message-ID: <20020823230136.15407.qmail@sources.redhat.com> (raw) >Number: 7707 >Category: c++ >Synopsis: GCC 3.1.1 Optimization incomplete/incorrect : leaks temporary object >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri Aug 23 16:06:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Konova Solutions Inc. >Release: GCC 3.1.1 >Organization: >Environment: RedHat Linux 7.3 Dual Intel Pentium III 833 MHz GCC compiled with: --prefix=/usr/gcc-3.1.1 --enable-threads=posix --enable-languages=c,c++ >Description: g++ seems not to optimize temporary objects copy correctly and results in a memory leak. The cpp file attached provides a example of how g++ fails to destruct a temporary object. The output of the example shows that 2 temporary objects are created (using copy ctor) while only one of them is destructed. A temporary object is created on the stack in method operator+(const foo&, const foo&). The result of the operator+ is passed to another method taking a const foo as parameter. Doing so, g++ calls the copy constructor. It is up to the compiler to actually call the copy ctor or not. g++ does not seem to optimize this copy, but then fails to destroy the object. The attachment contains the cpp and ii files. >How-To-Repeat: >Fix: Modifing the leakAFoo method to take a const foo& instead. g++ is still to blame. Either the optimization is incomplete, or some logic is erronous when destroying temporary objects. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-08-23 23:06 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-08-23 16:36 plaflamme [this message] 2002-08-23 23:06 Phil Edwards 2002-08-26 7:16 Philippe Laflamme 2002-08-30 2:26 Philippe Laflamme 2002-09-13 14:59 nathan
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=20020823230136.15407.qmail@sources.redhat.com \ --to=plaflamme@konova.com \ --cc=gcc-gnats@gcc.gnu.org \ --cc=lletourneau@konova.com \ /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).