This is the mail archive of the 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]

Fix an invalid C++ testcase

The pr8781.C testcase appears to have undefined behaviour as far as I
can tell. A function called noop is called with argument pred; this
creates a noop_t object which stores a reference to that argument, and
then the function returns the object. At that point I think the
reference becomes stale. This seems to be fixable by changing the pred
argument to be a reference itself.

Normally, inlining fixes up the situation, but this showed up as a
problem on a port where inlining was more difficult than usual.

Bootstrapped and tested on x86_64-linux. Ok?

	* g++.dg/tree-ssa/pr8781.C (noop): Make argument a reference.

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr8781.C b/gcc/testsuite/g++.dg/tree-ssa/pr8781.C
index cc518a0..a6050c4 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr8781.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr8781.C
@@ -13,7 +13,7 @@ public:
 template<typename predicate>
-inline noop_t<predicate> noop(const predicate pred) {
+inline noop_t<predicate> noop(const predicate &pred) {
     return noop_t<predicate>(pred);

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