1 /* PR middle-end/38364 */ 2 /* { dg-do run } */ 3 /* { dg-options "-O2 -ftrapv" } */ 4 5 extern void abort (void); 6 7 static inline short f1(short x,short y)8f1 (short x, short y) 9 { 10 if (x > 0) 11 { 12 if (y > 0) 13 { 14 if (x > __SHRT_MAX__ / y) 15 return x; 16 } 17 else if (y < (-__SHRT_MAX__ - 1) / x) 18 return x; 19 } 20 else 21 { 22 if (y > 0) 23 { 24 if (x < (-__SHRT_MAX__ - 1) / y) 25 return x; 26 } 27 else if (x != 0 && y < __SHRT_MAX__ / x) 28 return x; 29 } 30 return x * y; 31 } 32 33 static inline signed char f2(signed char x,signed char y)34f2 (signed char x, signed char y) 35 { 36 if (((x ^ y) & (((x ^ ((x ^ y) & (1 << (__CHAR_BIT__ - 1)))) - y) ^ y)) < 0) 37 return x; 38 return x - y; 39 } 40 41 unsigned int v; 42 43 int f3(int x,unsigned int y)44f3 (int x, unsigned int y) 45 { 46 f1 (1, 1); 47 return 1; 48 } 49 50 int f4(unsigned short x)51f4 (unsigned short x) 52 { 53 v = x; 54 return 1; 55 } 56 57 int f5(int x)58f5 (int x) 59 { 60 if (f2 (x, 1)) 61 f1 (1, f4 (1)); 62 return x; 63 } 64 65 int f6(unsigned int x)66f6 (unsigned int x) 67 { 68 f4 (x < (1 != f5 (0))); 69 return x; 70 } 71 72 int main(void)73main (void) 74 { 75 f6 (1); 76 if (v != 0) 77 abort (); 78 return 0; 79 } 80