* [pushed] c++: add NRV testcase [PR58050]
@ 2023-06-07 1:29 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-06-07 1:29 UTC (permalink / raw)
To: gcc-patches
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
diff --git a/gcc/testsuite/g++.dg/opt/nrv24.C b/gcc/testsuite/g++.dg/opt/nrv24.C
new file mode 100644
index 00000000000..7a7a59b26f7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/nrv24.C
@@ -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();}
+}
base-commit: 29c82c6ca929e0f5eccfe038dea71177d814c6b7
--
2.31.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-07 1:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 1:29 [pushed] c++: add NRV testcase [PR58050] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).