[clang] [C] Disable use of NRVO (PR #101038)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 29 12:33:04 PDT 2024
efriedma-quic wrote:
>So I think this supports the notion that this should be a dialect, and we have to wire defaults differently in MSVC mode as well.
I doubt anyone is intentionally depending on equality here.
> C++ does have some restrictions on accessing objects that are being initialized through other names. It's possible that they're strong enough to satisfy the ABI rule here through a sort of reverse of the normal analysis: basically, any program that would violate the ABI rule is actually incorrect because of the semantic restriction. If not, I think we may need to force copies of trivial return types in the caller in C++. We can consider that separately, though.
I suspect it isn't legal to actually access the object through another pointer while it's being constructed, but that doesn't help if the user is just doing a pointer equality comparison. And C++17 rules forbid a copy on the caller side: "guaranteed copy elision" means semantically, there is no copy.
https://github.com/llvm/llvm-project/pull/101038
More information about the cfe-commits
mailing list