From bc7ddafc93f1b30fa39e7f47f62b41ae3ed6a07b Mon Sep 17 00:00:00 2001 From: Paul Marinescu Date: Mon, 8 Dec 2014 01:07:52 +0000 Subject: Fix overshift check Shifting by bitwidth-1 is valid --- test/regression/2014-12-08-ashr.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/regression/2014-12-08-ashr.c (limited to 'test') diff --git a/test/regression/2014-12-08-ashr.c b/test/regression/2014-12-08-ashr.c new file mode 100644 index 00000000..3fe7f62b --- /dev/null +++ b/test/regression/2014-12-08-ashr.c @@ -0,0 +1,29 @@ +// RUN: %llvmgcc %s -emit-llvm -g -O0 -c -o %t.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out -exit-on-error %t.bc + +#include +#include + +int f1(int a, int b) { + return a + b; +} + +int f2(int a, int b) { + int i; + for (i = 0; i < sizeof(b) * 8; i++) + a += (((b >> i) & 1) << i); + + return a; +} + +int main(int argc, char **argv) { + int a, b; + klee_make_symbolic(&a, sizeof(a), "a"); + klee_make_symbolic(&b, sizeof(b), "b"); + + klee_assert(f1(a, b) == f2(a, b)); + + return 0; +} + -- cgit 1.4.1