mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
add compile-error test: bitcast
Issue fixed by an unknown commit. closes #3818
This commit is contained in:
parent
4848b28ec8
commit
f6d384450f
@ -6842,4 +6842,19 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:8:23: error: use of undefined value here causes undefined behavior",
|
||||
"tmp.zig:14:23: error: use of undefined value here causes undefined behavior",
|
||||
});
|
||||
|
||||
cases.add("issue #3818: bitcast from parray/slice to u16",
|
||||
\\export fn foo1() void {
|
||||
\\ var bytes = [_]u8{1, 2};
|
||||
\\ const word: u16 = @bitCast(u16, bytes[0..]);
|
||||
\\}
|
||||
\\export fn foo2() void {
|
||||
\\ var bytes: []u8 = &[_]u8{1, 2};
|
||||
\\ const word: u16 = @bitCast(u16, bytes);
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",
|
||||
"tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16",
|
||||
"tmp.zig:7:37: note: referenced here",
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user