const std = @import("std");
pub const panic = std.debug.no_panic;
export fn ok() bool {
var buffer: [5]u8 align(4) = .{ 1, 2, 3, 4, 5 };
const s = gimme(@ptrCast(buffer[1..]));
return s.a == 0x02030405;
}
const S = extern struct {
a: u32,
};
fn gimme(p: *align(1) S) S {
return p.*;
}
Generates this LLVM IR:
; Function Attrs: noredzone nounwind uwtable
define internal fastcc void @test.gimme(ptr noalias sret(%test.S) nonnull %0, ptr align 1 nonnull %1) unnamed_addr #0 {
2:
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %0, ptr align 4 %1, i64 4, i1 false)
ret void
}
Bad alignment on the memcpy.
Generates this LLVM IR:
Bad alignment on the memcpy.