File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -14,3 +14,30 @@ MyClass create_object(bool condition) {
1414 }
1515 return obj2; // expected-warning{{not eliding copy on return}}
1616}
17+
18+ MyClass create_object2 (){
19+ MyClass obj (1 );
20+ return obj; // no warning
21+ }
22+
23+ template <typename T>
24+ T create_object3 (){
25+ T obj (1 );
26+ return obj; // no warning
27+ }
28+
29+ // Known issue: if a function template uses a
30+ // deduced return type (i.e. auto or decltype(auto)),
31+ // then NRVO is not applied for any instantiation of
32+ // that function template
33+ // (see https://github.com/llvm/llvm-project/issues/95280).
34+ template <typename T>
35+ auto create_object4 (){
36+ T obj (1 );
37+ return obj; // expected-warning{{not eliding copy on return}}
38+ }
39+
40+ void init_templates (){
41+ create_object3<MyClass>(); // no warning
42+ create_object4<MyClass>(); // expected-note {{in instantiation of function template specialization 'create_object4<MyClass>' requested here}}
43+ }
You can’t perform that action at this time.
0 commit comments