aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-19 17:50:37 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-19 17:50:37 -0400
commit3dbed54294bc6769f64fc8bd23b98605d009677c (patch)
tree526bd9f01b83185dad4bbf91b5a238c43d6aa7a9 /test
parent07c5e906010e85d7e6560dc3ed398d7e4b284ec0 (diff)
downloadzig-3dbed54294bc6769f64fc8bd23b98605d009677c.tar.gz
zig-3dbed54294bc6769f64fc8bd23b98605d009677c.zip
fix @bitCast of packed struct literal
closes #3042
Diffstat (limited to 'test')
-rw-r--r--test/stage1/behavior/bitcast.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/stage1/behavior/bitcast.zig b/test/stage1/behavior/bitcast.zig
index 92777e3d12..125e4cce54 100644
--- a/test/stage1/behavior/bitcast.zig
+++ b/test/stage1/behavior/bitcast.zig
@@ -131,3 +131,11 @@ test "bitcast literal [4]u8 param to u32" {
const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 });
expect(ip == maxInt(u32));
}
+
+test "bitcast packed struct literal to byte" {
+ const Foo = packed struct {
+ value: u8,
+ };
+ const casted = @bitCast(u8, Foo{ .value = 0xF });
+ expect(casted == 0xf);
+}