1  /* { dg-do run } */
       2  /* { dg-require-effective-target int128 } */
       3  /* { dg-options "-fsanitize=signed-integer-overflow" } */
       4  /* { dg-options "-fsanitize=signed-integer-overflow -Wno-volatile" { target c++ } } */
       5  
       6  /* 2^127 - 1 */
       7  #define INT128_MAX (__int128) (((unsigned __int128) 1 << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 1)) - 1)
       8  #define INT128_MIN (-INT128_MAX - 1)
       9  
      10  int
      11  main (void)
      12  {
      13    volatile __int128 i = INT128_MAX;
      14    volatile __int128 j = 1;
      15    volatile __int128 k = i + j;
      16    k = j + i;
      17    i++;
      18    j = INT128_MAX - 100;
      19    j += (1 << 10);
      20  
      21    j = INT128_MIN;
      22    i = -1;
      23    k = i + j;
      24    k = j + i;
      25    j--;
      26    j = INT128_MIN + 100;
      27    j += -(1 << 10);
      28  
      29    i = INT128_MAX;
      30    j = 2;
      31    k = i * j;
      32  
      33    i = INT128_MIN;
      34    i = -i;
      35  
      36    return 0;
      37  }
      38  
      39  /* { dg-output "signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      40  /* { dg-output "\[^\n\r]*signed integer overflow: 1 \\+ 0x7fffffffffffffffffffffffffffffff cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      41  /* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      42  /* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffff9b \\+ 1024 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      43  /* { dg-output "\[^\n\r]*signed integer overflow: -1 \\+ 0x80000000000000000000000000000000 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      44  /* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000000 \\+ -1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      45  /* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      46  /* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000064 \\+ -1024 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      47  /* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\* 2 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
      48  /* { dg-output "\[^\n\r]*negation of 0x80000000000000000000000000000000 cannot be represented in type '__int128'; cast to an unsigned type to negate this value to itself" } */