public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/16982] wrong copy ctor called Date: Wed, 11 Aug 2004 18:12:00 -0000 [thread overview] Message-ID: <20040811181206.3419.qmail@sourceware.org> (raw) In-Reply-To: <20040811154232.16982.boris@kolpackov.net> ------- Additional Comments From bangerth at dealii dot org 2004-08-11 18:12 ------- Here's a testcase that's slightly simpler to understand: -------------------- #include <iostream> extern "C" void abort (); #define WHEREAMI std::cout << __PRETTY_FUNCTION__ << std::endl struct base { base () {WHEREAMI;} base (base const&) { WHEREAMI; abort (); } }; struct derived : base { derived () { WHEREAMI; } derived (derived const&) : base () { WHEREAMI; } }; struct s { operator derived () { WHEREAMI; return derived (); } }; int main () { s s; base const& b (s); } ------------------------------- With 3.4, we get this output: g/x> ./a.out s::operator derived() base::base() derived::derived() base::base(const base&) Aborted In other words, the abort happens when the temporary returned from the call to s::operator derived is casted to a reference of the base class. I am pretty sure the compiler is allowed to do so, but don't right now have the correct section of the standard available. In any case, the question may be moot, since with mainline we get this: g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ x.cc g/x> ./a.out s::operator derived() base::base() derived::derived() I.e. there is no abort and the program does what you expect. W. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED Target Milestone|--- |3.5.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16982
prev parent reply other threads:[~2004-08-11 18:12 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-08-11 15:42 [Bug c++/16982] New: " boris at kolpackov dot net 2004-08-11 16:21 ` [Bug c++/16982] " pinskia at gcc dot gnu dot org 2004-08-11 16:31 ` boris at kolpackov dot net 2004-08-11 18:12 ` bangerth at dealii dot org [this message]
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=20040811181206.3419.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).