summaryrefslogtreecommitdiff
path: root/lib/ubsan/lit_tests/Integer/negate-overflow.cpp
blob: 58f1b4870dd0c04aadb8b9068139887c6a0ab0b2 (plain)
1
2
3
4
5
6
7
// RUN: %clang -fcatch-undefined-behavior %s -o %t && %t 2>&1 | FileCheck %s

int main() {
  -unsigned(-0x7fffffff - 1); // ok
  // CHECK: negate-overflow.cpp:6:10: fatal error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
  return -(-0x7fffffff - 1);
}