diff --git a/src/configure.in b/src/configure.in
index fde19017ea1853b3366816d8b13f199375a8cfb9..5a2e1a1a4f4a0ccd46625a7d604bffd599d5306c 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -4689,9 +4689,10 @@ AC_CACHE_VAL(pike_cv_hardware_stack_direction,
 [
   AC_TRY_RUN([
 #include <stdio.h>
+static int (* volatile find_stack_direction_funptr)(void *foo, int cnt);
 static int find_stack_direction(void *foo, int cnt)
 {
-  if (cnt) return 1*find_stack_direction(foo, cnt>>1);
+  if (cnt) return 1*find_stack_direction_funptr(foo, cnt>>1);
   if (((void *)&foo) > foo) {
     return 1;
   } else {
@@ -4699,7 +4700,10 @@ static int find_stack_direction(void *foo, int cnt)
   }
 }
 
-int main() { void *bar; exit( find_stack_direction(&bar, 0x10) > 0); }
+int main() {
+  find_stack_direction_funptr = &find_stack_direction;
+  void *bar; exit( find_stack_direction_funptr(&bar, 0x10) > 0);
+}
   ], [ pike_cv_hardware_stack_direction=down
   ], [ pike_cv_hardware_stack_direction=up
   ], [