add compile error for @ptrCast 0 bit type to non-0 bit type
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@ptrCast a 0 bit type to a non- 0 bit type",
|
||||
\\export fn entry() bool {
|
||||
\\ var x: u0 = 0;
|
||||
\\ const p = @ptrCast(?*u0, &x);
|
||||
\\ return p == null;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:15: error: '*u0' and '?*u0' do not have the same in-memory representation",
|
||||
".tmp_source.zig:3:31: note: '*u0' has no in-memory bits",
|
||||
".tmp_source.zig:3:24: note: '?*u0' has in-memory bits",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"comparing a non-optional pointer against null",
|
||||
\\export fn entry() void {
|
||||
|
||||
Reference in New Issue
Block a user