| ... | @@ -203,6 +203,37 @@ test "comptime ptrcast keeps larger alignment" { | ... | @@ -203,6 +203,37 @@ test "comptime ptrcast keeps larger alignment" { |
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | | 205 | |
| | 206 | test "ptrcast of const integer has the correct object size" { |
| | 207 | const is_value = ~@intCast(isize, std.math.minInt(isize)); |
| | 208 | const is_bytes = @ptrCast([*]const u8, &is_value)[0..@sizeOf(isize)]; |
| | 209 | if (@sizeOf(isize) == 8) { |
| | 210 | switch (native_endian) { |
| | 211 | .Little => { |
| | 212 | try expect(is_bytes[0] == 0xff); |
| | 213 | try expect(is_bytes[1] == 0xff); |
| | 214 | try expect(is_bytes[2] == 0xff); |
| | 215 | try expect(is_bytes[3] == 0xff); |
| | 216 | |
| | 217 | try expect(is_bytes[4] == 0xff); |
| | 218 | try expect(is_bytes[5] == 0xff); |
| | 219 | try expect(is_bytes[6] == 0xff); |
| | 220 | try expect(is_bytes[7] == 0x7f); |
| | 221 | }, |
| | 222 | .Big => { |
| | 223 | try expect(is_bytes[0] == 0x7f); |
| | 224 | try expect(is_bytes[1] == 0xff); |
| | 225 | try expect(is_bytes[2] == 0xff); |
| | 226 | try expect(is_bytes[3] == 0xff); |
| | 227 | |
| | 228 | try expect(is_bytes[4] == 0xff); |
| | 229 | try expect(is_bytes[5] == 0xff); |
| | 230 | try expect(is_bytes[6] == 0xff); |
| | 231 | try expect(is_bytes[7] == 0xff); |
| | 232 | }, |
| | 233 | } |
| | 234 | } |
| | 235 | } |
| | 236 | |
| 206 | test "implicit optional pointer to optional anyopaque pointer" { | 237 | test "implicit optional pointer to optional anyopaque pointer" { |
| 207 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 238 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 208 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 239 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |