public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fabien.picarougne@univ-nantes.fr" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61655] New: Copy constructor not called on CRTP schema Date: Mon, 30 Jun 2014 07:38:00 -0000 [thread overview] Message-ID: <bug-61655-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61655 Bug ID: 61655 Summary: Copy constructor not called on CRTP schema Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fabien.picarougne@univ-nantes.fr Created attachment 33033 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33033&action=edit Illustration of the problem When using a CRTP pattern on a class and returning an object of this class in a function, the copy constructor is not called. See test attached file that illustrate the problem. Output on gcc 4.9.0 is CBase::CBase() CDerived::CDerived() CBase::CBase() CDerived::CDerived() before test: operator* CBase::CBase() CDerived::CDerived() end operator* CBase::Display() after test: CDerived::~CDerived() CBase::~CBase() CDerived::~CDerived() CBase::~CBase() CDerived::~CDerived() CBase::~CBase() but the expected outpup is CBase::CBase() CDerived::CDerived() CBase::CBase() CDerived::CDerived() before test: operator* CBase::CBase() CDerived::CDerived() end operator* CBase::CBase(const CBase &obj) CDerived::CDerived(const CDerived &obj) CDerived::~CDerived() CBase::~CBase() CBase::Display() after test: CDerived::~CDerived() CBase::~CBase() CDerived::~CDerived() CBase::~CBase() CDerived::~CDerived() CBase::~CBase() This code works fine on MSVC2013 C++ compiler
next reply other threads:[~2014-06-30 7:38 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-06-30 7:38 fabien.picarougne@univ-nantes.fr [this message] 2014-06-30 7:46 ` [Bug c++/61655] " glisse at gcc dot gnu.org 2014-06-30 7:49 ` pinskia at gcc dot gnu.org 2014-06-30 8:17 ` fabien.picarougne@univ-nantes.fr 2014-06-30 8:29 ` glisse at gcc dot gnu.org
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=bug-61655-4@http.gcc.gnu.org/bugzilla/ \ --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).