From 6f5ad518165085d2b6fe4d20cba3cefc229bb656 Mon Sep 17 00:00:00 2001 From: acqn Date: Tue, 23 Feb 2021 13:47:39 +0800 Subject: [PATCH] Added testcase for Issue #1408. --- test/val/bug1408.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/val/bug1408.c diff --git a/test/val/bug1408.c b/test/val/bug1408.c new file mode 100644 index 000000000..8ecc1be68 --- /dev/null +++ b/test/val/bug1408.c @@ -0,0 +1,41 @@ +/* Bug #1408: Signed char type comparisons with unsigned numeric constants */ + +#include + +static int failures = 0; +static signed char x = -1; + +int main(void) +{ + if (!(x > -2u)) { + printf("x > -2u should be true\n"); + ++failures; + } + if (!(x > 0u)) { + printf("x > 0u should be true\n"); + ++failures; + } + if (!(x > 255u)) { + printf("x > 255u should be true\n"); + ++failures; + } + + if (!(-2u < x)) { + printf("-2u < x should be true\n"); + ++failures; + } + if (!(0u < x)) { + printf("0u < x should be true\n"); + ++failures; + } + if (!(255u < x)) { + printf("255u < x should be true\n"); + ++failures; + } + + if (failures != 0) { + printf("Failures: %d\n", failures); + } + + return failures; +}