@ptrCast preserves larger alignment if applicable

See #37
This commit is contained in:
Andrew Kelley
2017-08-30 01:12:47 -04:00
parent fa9006f8d1
commit 56cc62a9c7
2 changed files with 101 additions and 76 deletions

View File

@@ -136,3 +136,10 @@ test "generic function with align param" {
}
fn whyWouldYouEverDoThis(comptime align_bytes: u8) align align_bytes -> u8 { 0x1 }
test "@ptrCast preserves alignment of bigger source" {
var x: u32 align 16 = 1234;
const ptr = @ptrCast(&u8, &x);
assert(@typeOf(ptr) == &align 16 u8);
}