From: Martin Sebor Date: Tue, 6 Aug 2019 00:08:45 +0000 (+0000) Subject: PR c++/60517 - warning/error for taking address of member of a temporary object X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57436cb10e04b6aeb3bf998a48d6c6ea47abbad6;p=gcc.git PR c++/60517 - warning/error for taking address of member of a temporary object testsuite/ChangeLog: * g++.dg/pr60517.C: New test. From-SVN: r274130 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34a919901ff..4b871aaa9a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-05 Martin Sebor + + PR c++/60517 + * g++.dg/pr60517.C: New test. + 2019-08-02 Tom Honermann PR c++/88095 diff --git a/gcc/testsuite/g++.dg/pr60517.C b/gcc/testsuite/g++.dg/pr60517.C new file mode 100644 index 00000000000..2997fa1cf52 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr60517.C @@ -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]; +}