langref: docs for invalid error set cast and incorrect pointer alignment
also add detection of incorrect pointer alignment at compile-time of pointers that were constructed with `@intToPtr`.
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"bad @alignCast at comptime",
|
||||
\\comptime {
|
||||
\\ const ptr = @intToPtr(*i32, 0x1);
|
||||
\\ const aligned = @alignCast(4, ptr);
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:3:35: error: pointer address 0x1 is not aligned to 4 bytes",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"@ptrToInt on *void",
|
||||
\\export fn entry() bool {
|
||||
|
||||
Reference in New Issue
Block a user