(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
ubsan/
pr109107-1.c
       1  /* PR sanitizer/109107 */
       2  /* { dg-do run { target int32 } } */
       3  /* { dg-options "-fsanitize=signed-integer-overflow" } */
       4  
       5  #define INT_MIN (-__INT_MAX__ - 1)
       6  int a = INT_MIN;
       7  const int b = 676540;
       8  
       9  __attribute__((noipa)) int
      10  foo ()
      11  {
      12    int c = a + 1 - (int) (short) b;
      13    return c;
      14  }
      15  
      16  int
      17  main ()
      18  {
      19    foo ();
      20    return 0;
      21  }
      22  
      23  /* { dg-output "signed integer overflow: -2147483647 - 21180 cannot be represented in type 'int'" } */