summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixuns-trunc-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/fixuns-trunc-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/fixuns-trunc-1.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fixuns-trunc-1.c b/gcc/testsuite/gcc.dg/fixuns-trunc-1.c
new file mode 100644
index 000000000..0d0942952
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fixuns-trunc-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+unsigned long foo(double d)
+{
+ return (unsigned long) d;
+}
+
+extern void abort(void);
+
+int main(void)
+{
+ double d;
+ unsigned long l;
+
+#ifdef __LP64__
+ d = 9223372036854775808.7;
+ l = 1LL << 63;
+
+ if (foo(d) != l)
+ abort();
+#endif
+
+ d = 122485.2;
+ l = 122485;
+
+ if (foo(d) != l)
+ abort();
+
+ return 0;
+}