diff options
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index d1e9f6d03a..a1dd33fb43 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,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 { \\ var x: i32 = 1; |
