This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61655] New: Copy constructor not called on CRTP schema
- From: "fabien dot picarougne at univ-nantes dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jun 2014 07:38:02 +0000
- Subject: [Bug c++/61655] New: Copy constructor not called on CRTP schema
- Auto-submitted: auto-generated
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