gcc/testsuite/gcc.c-torture/execute/981001-1.c
raw| 1 | void abort (void); |
| 2 | void exit (int); |
| 3 | |
| 4 | #define NG 0x100L |
| 5 | |
| 6 | unsigned long flg = 0; |
| 7 | |
| 8 | long sub (int n) |
| 9 | { |
| 10 | int a, b ; |
| 11 | |
| 12 | if (n >= 2) |
| 13 | { |
| 14 | if (n % 2 == 0) |
| 15 | { |
| 16 | a = sub (n / 2); |
| 17 | |
| 18 | return (a + 2 * sub (n / 2 - 1)) * a; |
| 19 | } |
| 20 | else |
| 21 | { |
| 22 | a = sub (n / 2 + 1); |
| 23 | b = sub (n / 2); |
| 24 | |
| 25 | return a * a + b * b; |
| 26 | } |
| 27 | } |
| 28 | else |
| 29 | return (long) n; |
| 30 | } |
| 31 | |
| 32 | int main (void) |
| 33 | { |
| 34 | if (sub (30) != 832040L) |
| 35 | flg |= NG; |
| 36 | |
| 37 | if (flg) |
| 38 | abort (); |
| 39 | |
| 40 | exit (0); |
| 41 | } |