about summary refs log tree commit diff homepage
path: root/test/Feature
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2014-12-19 16:47:28 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2014-12-19 16:47:28 +0000
commitad4f23ac1b1faa561d199b27e041e1a1afa3adcb (patch)
tree63c6d60e7c70e0a3148f34216b0877fb36448e7b /test/Feature
parent80f9833b31650a7cb76d2e6d74a073319b86e683 (diff)
parent4af13aa1ae965a3fff9f005a78674efdc49ce3f7 (diff)
downloadklee-ad4f23ac1b1faa561d199b27e041e1a1afa3adcb.tar.gz
Merge pull request #168 from willemp/fix-va-args-passing-for-big-types
Fix va args passing for big types
Diffstat (limited to 'test/Feature')
-rw-r--r--test/Feature/VarArgLongDouble.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/Feature/VarArgLongDouble.c b/test/Feature/VarArgLongDouble.c
new file mode 100644
index 00000000..ae553131
--- /dev/null
+++ b/test/Feature/VarArgLongDouble.c
@@ -0,0 +1,42 @@
+// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out %t.bc | FileCheck %s
+
+#include <stdarg.h>
+#include <assert.h>
+#include <stdio.h>
+
+void ld_after_zero(int first,...)
+{
+	va_list ap;
+	long double dub;
+
+	va_start(ap, first);
+
+	while (va_arg(ap, int) != 0)
+		;
+
+	dub = va_arg(ap, long double);
+
+	printf("%Lf\n", dub);
+
+}
+
+int main() {
+  long double dub = 1.123456;
+  int zero = 0;
+  int one = 1;
+
+  // AMD64-ABI 3.5.7p5: Step 7. Align l->overflow_arg_area upwards to a 16
+  // byte boundary if alignment needed by type exceeds 8 byte boundary.
+  // 
+  // the long double dub requires 16 byte alignment.
+  // we try passing one,zero and one, one, zero
+  // at least on those will align dub such that it needs the extra alignment
+  ld_after_zero(one, zero, dub);
+  // CHECK: 1.123456
+  ld_after_zero(one, one, zero, dub);
+  // CHECK-NEXT: 1.123456
+
+  return 0;
+}