infinite recursion detected in gold testcase

Message ID YdVmegH0d/gPlJM9@squeak.grove.modra.org
State New
Headers show
Series
  • infinite recursion detected in gold testcase
Related show

Commit Message

H.J. Lu via Binutils Jan. 5, 2022, 9:35 a.m.
gold/testsuite/icf_test.cc:32:5: error: infinite recursion detected [-Werror=infinite-recursion]
   32 | int kept_func()
      |     ^~~~~~~~~

	* testsuite/icf_test.cc: Avoid infinite recursion error.


-- 
Alan Modra
Australia Development Lab, IBM

Comments

H.J. Lu via Binutils Jan. 5, 2022, 5:21 p.m. | #1
>         * testsuite/icf_test.cc: Avoid infinite recursion error.


Thanks!

-cary

Patch

diff --git a/gold/testsuite/icf_test.cc b/gold/testsuite/icf_test.cc
index 7abd2ae6328..d7de701cba0 100644
--- a/gold/testsuite/icf_test.cc
+++ b/gold/testsuite/icf_test.cc
@@ -29,19 +29,21 @@  int common()
   return 1;
 }
 
-int kept_func()
+int kept_func(int i)
 {
   common();
   // Recursive call.
-  kept_func();
+  if (i)
+    kept_func(i - 1);
   return 1;
 }
 
-int folded_func()
+int folded_func(int i)
 {
   common();
   // Recursive call.
-  folded_func();
+  if (i)
+    folded_func(i - 1);
   return 1;
 }