[pushed] c++: add NRV testcase [PR58050]
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Testing passed
|
Commit Message
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
This was fixed in GCC 10.
PR c++/58050
gcc/testsuite/ChangeLog:
* g++.dg/opt/nrv24.C: New test.
---
gcc/testsuite/g++.dg/opt/nrv24.C | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/opt/nrv24.C
base-commit: 29c82c6ca929e0f5eccfe038dea71177d814c6b7
new file mode 100644
@@ -0,0 +1,18 @@
+// PR c++/58050
+// { dg-do link }
+
+struct B {
+ B() { }
+ B(const B&); // not defined, link error on unnecessary copy
+ ~B() { }
+};
+struct A {
+ static B make() { return B(); }
+} a;
+A *ap() { return &a; }
+int main () {
+ {B b = A::make();}
+ {B B = a.make();}
+ {B b = ap()->make();}
+ {B b = A().make();}
+}