[PATCH] A testcase for PR 30590

Seongbae Park seongbae.park@gmail.com
Mon Mar 19 22:59:00 GMT 2007


Hi,

This is a testcase from PR 30590 for invalid tree-nrv optimization.
Tested using RUNTESTFLAGS= with compilers before and after the fix/

2007-03-19  Seongbae Park <seongbae.park@gmail.com>

        * g++.dg/opt/pr30590.C: New testcase.
-- 
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
-------------- next part --------------
Index: gcc/testsuite/g++.dg/opt/pr30590.C
===================================================================
--- gcc/testsuite/g++.dg/opt/pr30590.C	(revision 0)
+++ gcc/testsuite/g++.dg/opt/pr30590.C	(revision 0)
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+struct test
+{
+  int type;
+  char buffer[4242]; /* should trigger pass-by-reference */
+};
+
+int flag = 0;
+
+struct test
+reset (void)
+{
+  struct test retval;
+  retval.type = 1;
+  return retval;
+}
+
+struct test
+test (void)
+{
+  struct test result;
+  result.type = 0;
+
+  for (int i = 0; i < 2; ++i)
+    {
+      struct test candidate = reset ();
+      if (flag)
+        result = candidate;
+    }
+
+  return result;
+}
+
+int
+main (void)
+{
+  struct test result = test ();
+  return result.type;
+}


More information about the Gcc-patches mailing list