1*b8aae540SGreg Fitzgerald // RUN: %clangxx -fsanitize=signed-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s
2ba869e79SAlexey Samsonov 
3ba869e79SAlexey Samsonov #include <stdint.h>
4ba869e79SAlexey Samsonov 
main()5ba869e79SAlexey Samsonov int main() {
6ba869e79SAlexey Samsonov   // These promote to 'int'.
7ba869e79SAlexey Samsonov   (void)(int8_t(-2) * int8_t(0x7f));
8ba869e79SAlexey Samsonov   (void)(int16_t(0x7fff) * int16_t(0x7fff));
9ba869e79SAlexey Samsonov   (void)(uint16_t(0xffff) * int16_t(0x7fff));
10ba869e79SAlexey Samsonov   (void)(uint16_t(0xffff) * uint16_t(0x8000));
11ba869e79SAlexey Samsonov 
12ba869e79SAlexey Samsonov   // CHECK: mul-overflow.cpp:13:27: runtime error: signed integer overflow: 65535 * 32769 cannot be represented in type 'int'
13ba869e79SAlexey Samsonov   (void)(uint16_t(0xffff) * uint16_t(0x8001));
14ba869e79SAlexey Samsonov }
15