view gcc/testsuite/c-c++-common/ubsan/overflow-add-3.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do run } */
/* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable -fno-sanitize-recover=signed-integer-overflow" } */
/* { dg-shouldfail "ubsan" } */

#define INT_MAX __INT_MAX__
#define INT_MIN (-__INT_MAX__ - 1)

int
main (void)
{
  volatile int j = INT_MAX;
  volatile int i = 1;
  volatile int k = j + i;
  return 0;
}

/* { dg-output "signed integer overflow: 2147483647 \\+ 1 cannot be represented in type 'int'" } */