(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
20020423-1.c
       1  /* PR c/5430 */
       2  /* Verify that the multiplicative folding code is not fooled
       3     by the mix between signed variables and unsigned constants. */
       4  
       5  extern void abort (void);
       6  extern void exit (int);
       7  
       8  int main (void)
       9  {
      10    int my_int = 924;
      11    unsigned int result;
      12  
      13    result = ((my_int*2 + 4) - 8U) / 2;
      14    if (result != 922U)
      15      abort();
      16           
      17    result = ((my_int*2 - 4U) + 2) / 2;
      18    if (result != 923U)
      19      abort();
      20  
      21    result = (((my_int + 2) * 2) - 8U - 4) / 2;
      22    if (result != 920U)
      23      abort();
      24    result = (((my_int + 2) * 2) - (8U + 4)) / 2;
      25    if (result != 920U)
      26      abort();
      27  
      28    result = ((my_int*4 + 2U) - 4U) / 2;
      29    if (result != 1847U)
      30      abort();
      31  
      32    exit(0);
      33  }