Open aywala opened 1 week ago
@llvm/issue-subscribers-c-14
Author: Aywala (aywala)
@llvm/issue-subscribers-clang-frontend
Author: Aywala (aywala)
I'm not sure whether RVO should be mandatory or disallowed in constant evaluation in C++11/14. At the time when CWG2022 got accepted, RVO was considered as copy elision. However, since C++17 (thanks to P0135R1), RVO is no longer considered as copy elision.
CC @zygoloid @jicama.
With -std=c++14 flag, Clang performs the copy elision for the return statement in foo(), but still reports error about the copy constructor. I know copy elision is not guaranteed with pre-C++17, but since clang does perform it, there should not be an error. When C++ standard is not specified, Clang-15 reports an error while higher versions do not. GCC and MSVC have no problem with this code sample.
https://godbolt.org/z/af5aGzn1a