modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr19606.c (about) 1 /* PR c/19606 2 The C front end used to shorten the type of a division to a type 3 that does not preserve the semantics of the original computation. 4 Make sure that won't happen. */ 5 6 signed char a = -4; 7 8 int 9 foo (void) 10 { 11 return ((unsigned int) (signed int) a) / 2LL; 12 } 13 14 int 15 bar (void) 16 { 17 return ((unsigned int) (signed int) a) % 5LL; 18 } 19 20 int 21 main (void) 22 { 23 int r; 24 25 r = foo (); 26 if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL) 27 abort (); 28 29 r = bar (); 30 if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL) 31 abort (); 32 33 exit (0); 34 }