diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-09-20 22:02:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-20 22:02:36 -0400 |
| commit | 62ecc154d9ad065aee57d81afd3a478dd8360fb7 (patch) | |
| tree | 52f17b58d87a2ef83f2a1607f0aecbee31c33661 /test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig | |
| parent | 521c753fda3cd5ebb79752287ef3c87d84f8d5c3 (diff) | |
| parent | eef653904916dc19540458199366807f8837bf98 (diff) | |
| download | zig-62ecc154d9ad065aee57d81afd3a478dd8360fb7.tar.gz zig-62ecc154d9ad065aee57d81afd3a478dd8360fb7.zip | |
Merge pull request #12904 from Vexu/ptrcast
stage2: pointer casting fixes and improvements
Diffstat (limited to 'test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig')
| -rw-r--r-- | test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig new file mode 100644 index 0000000000..9cc5ed3a42 --- /dev/null +++ b/test/cases/compile_errors/increase_pointer_alignment_in_ptrCast.zig @@ -0,0 +1,13 @@ +export fn entry() u32 { + var bytes: [4]u8 = [_]u8{0x01, 0x02, 0x03, 0x04}; + const ptr = @ptrCast(*u32, &bytes[0]); + return ptr.*; +} + +// error +// backend=stage2 +// target=native +// +// :3:17: error: cast increases pointer alignment +// :3:32: note: '*u8' has alignment '1' +// :3:26: note: '*u32' has alignment '4' |
