Closed Quuxplusone closed 13 years ago
Attached Demo.zip
(34859 bytes, application/zip): Xcode 4 project that demonstrates the problem with minimal code
The given testcase has undefined behavior given that it doesn't define a copy constructor for D. However, ideally we shouldn't be calling it (i.e. this is a missed case of NRVO).
Yes, thanks, when compiled with llvm-gcc, only the assignment operator is invoked; when compiled with clang first the copy constructor (when added to the code) is invoked, and then the assignment operator. It would be a valuable optimization to not call the copy constructor.
This is also rdar://problem/10050178.
Fixed in Clang r139175.
(In reply to comment #4)
> Fixed in Clang r139175.
Excellent!
Demo.zip
(34859 bytes, application/zip)