aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr97505.c
blob: f01d912067a0b38692d93cee68ced24d43b1dc69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// { dg-do compile }
// { dg-options "-Os -fsanitize=signed-integer-overflow -fdump-tree-evrp" }

// Test that .UBSAN_CHECK_SUB(y, x) is treated as y-x for range
// purposes, where X and Y are related to each other.
//
// This effectively checks that range relationals work with builtins.

void unreachable();

int foobar(int x, int y)
{
  if (x < y)
    {
      int z = y - x;
      if (z == 0)
        unreachable();
      return z;
    }
  return 5;
}

// { dg-final { scan-tree-dump-not "unreachable" "evrp" } }