aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/pr82072.c
blob: d5683406b141f2e3de45d1463115b3214af33c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* PR sanitizer/82072 */
/* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow" } */

int
main ()
{
  long long l = -__LONG_LONG_MAX__ - 1;
  int i = 0;
  asm volatile ("" : "+r" (i));
  i -= l;
  asm volatile ("" : "+r" (i));
  i = -l;
  asm volatile ("" : "+r" (i));
  return 0;
}

/* { dg-output "signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*negation of -9223372036854775808 cannot be represented in type 'long long int'\[^\n\r]*; cast to an unsigned type to negate this value to itself" } */