aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-22 11:09:17 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-22 11:09:17 -0500
commit2fe8a0831f2830a3357cdf65b2ebfe1214b13a83 (patch)
tree45eeb3b551fa3a9745101cec435d874347bf24bb /test
parentd0c39895aae085e421ada85d9d07f417d549c7e6 (diff)
downloadzig-2fe8a0831f2830a3357cdf65b2ebfe1214b13a83.tar.gz
zig-2fe8a0831f2830a3357cdf65b2ebfe1214b13a83.zip
add regression test for bitcast to array
closes #421
Diffstat (limited to 'test')
-rw-r--r--test/stage1/behavior.zig1
-rw-r--r--test/stage1/behavior/bugs/421.zig16
2 files changed, 17 insertions, 0 deletions
diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig
index 525d65d7fc..f7fc1c42a4 100644
--- a/test/stage1/behavior.zig
+++ b/test/stage1/behavior.zig
@@ -20,6 +20,7 @@ comptime {
_ = @import("behavior/bugs/1486.zig");
_ = @import("behavior/bugs/1851.zig");
_ = @import("behavior/bugs/394.zig");
+ _ = @import("behavior/bugs/421.zig");
_ = @import("behavior/bugs/655.zig");
_ = @import("behavior/bugs/656.zig");
_ = @import("behavior/bugs/726.zig");
diff --git a/test/stage1/behavior/bugs/421.zig b/test/stage1/behavior/bugs/421.zig
new file mode 100644
index 0000000000..e5f67f61b7
--- /dev/null
+++ b/test/stage1/behavior/bugs/421.zig
@@ -0,0 +1,16 @@
+const assert = @import("std").debug.assert;
+
+test "bitCast to array" {
+ comptime testBitCastArray();
+ testBitCastArray();
+}
+
+fn testBitCastArray() void {
+ assert(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
+}
+
+fn extractOne64(a: u128) u64 {
+ const x = @bitCast([2]u64, a);
+ return x[1];
+}
+