about summary refs log tree commit diff homepage
path: root/test/regression/2016-12-14-alloc-alignment.c
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2017-02-28 16:15:27 +0000
committerGitHub <noreply@github.com>2017-02-28 16:15:27 +0000
commite21bf6f653b9c602fe21b74ff7c389aa2430b386 (patch)
tree02b0c15d4c53e885941d2119b272a6e8e83cab16 /test/regression/2016-12-14-alloc-alignment.c
parentbff9fb9277f890f2fd9b4acd3b9d5eed0e78f967 (diff)
parent479f8068a769885e0fb50bf37f886ef839e63609 (diff)
downloadklee-e21bf6f653b9c602fe21b74ff7c389aa2430b386.tar.gz
Merge pull request #547 from delcypher/fix_alignment_of_alloc_memory
Teach KLEE to respect the requested memory alignment of allocated memory
Diffstat (limited to 'test/regression/2016-12-14-alloc-alignment.c')
-rw-r--r--test/regression/2016-12-14-alloc-alignment.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/regression/2016-12-14-alloc-alignment.c b/test/regression/2016-12-14-alloc-alignment.c
new file mode 100644
index 00000000..db66d191
--- /dev/null
+++ b/test/regression/2016-12-14-alloc-alignment.c
@@ -0,0 +1,21 @@
+// RUN: %llvmgcc %s -Wall -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 <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+// Global should be aligned on a 128-byte boundary
+int foo __attribute__((aligned(128)));
+
+int main() {
+  int bar __attribute__((aligned(256)));
+
+  // Check alignment of global
+  assert(((size_t)&foo) % 128 == 0);
+
+  // Check alignment of local
+  assert(((size_t)&bar) % 256 == 0);
+  return 0;
+}