http://llvm.org/bugs/show_bug.cgi?id=11757
Bug #: 11757
Summary: Missed copy elision when using operator new
Product: clang
Version: 2.9
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
It seems clang misses the copy elision when an rvalue of some class is used for
copy construction through operator new.
This is demonstrated by the assertion failure of the following code:
#include <cassert>
#include <new>
class CopyCounter
{
private:
static int mCount;
public:
CopyCounter() { }
CopyCounter(const CopyCounter&) { ++mCount; }
static int Get() { return mCount; }
};
int CopyCounter::mCount = 0;
int main()
{
CopyCounter* f = new CopyCounter(CopyCounter());
assert(CopyCounter::Get() == 0);
delete f;
return 0;
}
I have tested this on 2.9 but I expect trunk is also affected because of a
similar problem reported to me by someone using a relatively recent checkout of
trunk.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs