nullptr.cpp added a comment. - C++11:
> [class.copy]p32: > When **the criteria for elision of a copy operation **are met or would be met > save for the fact that the source object is a function parameter, and the > object to be copied is designated by an lvalue, overload resolution to select > the constructor for the copy is first performed as if the object were > designated by an rvalue. //Thus should use rules at:// > [class.copy]p31: > — in a return statement in a function with a class return type, when the > expression is the name of a **non-volatile automatic object **... **Volatile automatic objects** cannot pass this check. - CWG1579: > When **the criteria for elision of a copy operation** are met and the object > to be copied is designated by an lvalue, **or when **the expression in a > return statement is a (possibly parenthesized) id-expression that names **an > object with automatic storage duration **declared in the body or > parameter-declaration-clause of the innermost enclosing function or > lambda-expression, overload resolution When the expression is the name of a **volatile automatic object**, the first condition will fail because the criteria for elision of a copy operation require a **non-volatile automatic object **. So take the ''**or when ...**'' branch, **volatile automatic objects** can pass this check. - C++14 is same as CWG1579. - C++17: > [class. copy. elision]p(3.1): > — If the expression in a return statement is a (possibly parenthesized) > id-expression that names **an object with automatic storage duration** ... **Volatile automatic objects** can also pass this check. - C++20: > [class. copy. elision]p3: > An implicitly movable entity is a variable of automatic storage duration that > is either **a non-volatile object** or an rvalue reference to a non-volatile > object type. > — If the expression in a return or co_return statement is a (possibly > parenthesized) id-expression that names an **implicitly movable entity** ... **Volatile automatic objects** cannot pass this check. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88295/new/ https://reviews.llvm.org/D88295 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits