(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
divconst-2.c
       1  long
       2  f (long x)
       3  {
       4    return x / (-0x7fffffffL - 1L);
       5  }
       6  
       7  long
       8  r (long x)
       9  {
      10    return x % (-0x7fffffffL - 1L);
      11  }
      12  
      13  /* Since we have a negative divisor, this equation must hold for the
      14     results of / and %; no specific results are guaranteed.  */
      15  long
      16  std_eqn (long num, long denom, long quot, long rem)
      17  {
      18    /* For completeness, a check for "ABS (rem) < ABS (denom)" belongs here,
      19       but causes trouble on 32-bit machines and isn't worthwhile.  */
      20    return quot * (-0x7fffffffL - 1L) + rem == num;
      21  }
      22  
      23  long nums[] =
      24  {
      25    -1L, 0x7fffffffL, -0x7fffffffL - 1L
      26  };
      27  
      28  main ()
      29  {
      30    int i;
      31  
      32    for (i = 0;
      33         i < sizeof (nums) / sizeof (nums[0]);
      34         i++)
      35      if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)
      36        abort ();
      37  
      38    exit (0);
      39  }