This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] add C++ test for PR60517


The expected diagnostic is now issued so I resolved the bug
and committed the test in r274130.

Martin

Index: gcc/testsuite/g++.dg/pr60517.C
===================================================================
--- gcc/testsuite/g++.dg/pr60517.C	(nonexistent)
+++ gcc/testsuite/g++.dg/pr60517.C	(revision 274130)
@@ -0,0 +1,22 @@
+// PR c++/60517 - warning/error for taking address of member of a temporary
+// object
+// { dg-do compile }
+
+class B
+{
+public:
+  double x[2];
+};
+
+class A
+{
+  B b;
+public:
+  B getB () { return b; }
+};
+
+double foo (A a)
+{
+ double * x = &(a.getB().x[0]); // { dg-error "taking address of rvalue" }
+  return x[0];
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]