(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
ubsan/
overflow-negate-3.c
       1  /* { dg-do run } */
       2  /* { dg-options "-fsanitize=signed-integer-overflow" } */
       3  
       4  #define INT_MIN (-__INT_MAX__ - 1)
       5  
       6  int
       7  main ()
       8  {
       9    int x = INT_MIN;
      10    int y;
      11    __asm__ volatile ("" : "+g" (x));
      12    y = -(-x);
      13    __asm__ volatile ("" : "+g" (y));
      14    y = -(-INT_MIN);
      15    __asm__ volatile ("" : "+g" (y));
      16  }
      17  
      18  /* { dg-output "negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
      19  /* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
      20  /* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
      21  /* { dg-output "\[^\n\r]*negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself" } */