public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/14035] New: Compiler generates spurious temporary @ 2004-02-05 23:12 austern at apple dot com 2004-02-14 20:11 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: austern at apple dot com @ 2004-02-05 23:12 UTC (permalink / raw) To: gcc-bugs Consider the following test case: #include <stdio.h> struct Blob { int x, y; Blob() { } Blob(const Blob &b) { printf("Copying %p to %p!!\n", &b, this); } }; struct Blobby : public Blob { }; struct Wooly { operator const Blobby & () { printf("Conversion operator yields: %p\n", &myBlobby); return myBlobby; } Blobby myBlobby; }; void catcher(const Blob &blo) { printf("catcher: %p\n", &blo); } int main() { Wooly wooly; catcher((const Blob &)wooly); // <-- generates a copy } Compiling and running this gives the following output: [tmp]$ ./a.out Conversion operator yields: 0xbffffd50 Copying 0xbffffd50 to 0xbffffd60!! catcher: 0xbffffd60 [tmp]$ This is wrong. The conversion operator yields a const Blobby&, and we're asking for a const Blob&. All we need to do is perform the derived-to-base standard conversion. Instead, for no apparent reason, the compiler invokes Blob's copy constructor and creates a temporary. Note that this test case really does need the explicit cast of wooly to const Blob&. Without the explicit cast we don't get a temporary. -- Summary: Compiler generates spurious temporary Product: gcc Version: 3.5.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: austern at apple dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-apple-darwin GCC host triplet: powerpc-apple-darwin GCC target triplet: powerpc-apple-darwin6.6 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com @ 2004-02-14 20:11 ` pinskia at gcc dot gnu dot org 2004-10-13 14:59 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " pinskia at gcc dot gnu dot org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-02-14 20:11 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-14 20:11 ------- Confirmed, related to 14140. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |rejects-valid, wrong-code Last reconfirmed|0000-00-00 00:00:00 |2004-02-14 20:11:20 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] [3.3/3.4/4.0 Regression] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com 2004-02-14 20:11 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org @ 2004-10-13 14:59 ` pinskia at gcc dot gnu dot org 2004-10-13 14:59 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-10-13 14:59 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |3.4.0 4.0.0 Known to work| |2.95.3 Summary|Compiler generates spurious |[3.3/3.4/4.0 Regression] |temporary |Compiler generates spurious | |temporary Target Milestone|--- |3.4.3 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com 2004-02-14 20:11 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org 2004-10-13 14:59 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " pinskia at gcc dot gnu dot org @ 2004-10-13 14:59 ` pinskia at gcc dot gnu dot org 2004-10-15 21:27 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " mmitchel at gcc dot gnu dot org ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-10-13 14:59 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-13 14:59 ------- *** Bug 14140 has been marked as a duplicate of this bug. *** -- What |Removed |Added ---------------------------------------------------------------------------- CC| |christian dot engstrom at | |glindra dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] [3.3/3.4/4.0 Regression] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com ` (2 preceding siblings ...) 2004-10-13 14:59 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org @ 2004-10-15 21:27 ` mmitchel at gcc dot gnu dot org 2004-10-19 23:30 ` mmitchel at gcc dot gnu dot org 2004-10-19 23:37 ` pinskia at gcc dot gnu dot org 5 siblings, 0 replies; 7+ messages in thread From: mmitchel at gcc dot gnu dot org @ 2004-10-15 21:27 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com |dot org | Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] [3.3/3.4/4.0 Regression] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com ` (3 preceding siblings ...) 2004-10-15 21:27 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " mmitchel at gcc dot gnu dot org @ 2004-10-19 23:30 ` mmitchel at gcc dot gnu dot org 2004-10-19 23:37 ` pinskia at gcc dot gnu dot org 5 siblings, 0 replies; 7+ messages in thread From: mmitchel at gcc dot gnu dot org @ 2004-10-19 23:30 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-10-19 23:30 ------- Fixed in GCC 4.0. Will not be fixed in GCC 3.4.x. -- What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/14035] [3.3/3.4/4.0 Regression] Compiler generates spurious temporary 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com ` (4 preceding siblings ...) 2004-10-19 23:30 ` mmitchel at gcc dot gnu dot org @ 2004-10-19 23:37 ` pinskia at gcc dot gnu dot org 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-10-19 23:37 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|3.4.3 |4.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14035 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-10-19 23:37 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-02-05 23:12 [Bug c++/14035] New: Compiler generates spurious temporary austern at apple dot com 2004-02-14 20:11 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org 2004-10-13 14:59 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " pinskia at gcc dot gnu dot org 2004-10-13 14:59 ` [Bug c++/14035] " pinskia at gcc dot gnu dot org 2004-10-15 21:27 ` [Bug c++/14035] [3.3/3.4/4.0 Regression] " mmitchel at gcc dot gnu dot org 2004-10-19 23:30 ` mmitchel at gcc dot gnu dot org 2004-10-19 23:37 ` pinskia at gcc dot gnu dot org
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).