modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr42231.c (about)

     1  extern void abort (void);
     2  
     3  static max;
     4  
     5  static void __attribute__((noinline)) storemax (int i)
     6  {
     7    if (i > max)
     8      max = i;
     9  }
    10  
    11  static int CallFunctionRec(int (*fun)(int depth), int depth) {
    12    if (!fun(depth)) {
    13      return 0;
    14    }
    15    if (depth < 10) {
    16      CallFunctionRec(fun, depth + 1);
    17    }
    18    return 1;
    19  }
    20  
    21  static int CallFunction(int (*fun)(int depth)) {
    22    return CallFunctionRec(fun, 1) && !fun(0);
    23  }
    24  
    25  static int callback(int depth) {
    26    storemax (depth);
    27    return depth != 0;
    28  }
    29  
    30  int main() {
    31    CallFunction(callback);
    32    if (max != 10)
    33      abort ();
    34    return 0;
    35  }