fix @bytesToSlice on a packed struct

closes #1551
This commit is contained in:
Andrew Kelley 2018-09-18 09:49:57 -04:00
parent 68c1d05917
commit d353d5aef8
No known key found for this signature in database
GPG Key ID: 4E7CD66038A4D47C
2 changed files with 13 additions and 0 deletions

View File

@ -18516,6 +18516,9 @@ static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionF
src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);
}
if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown)))
return ira->codegen->builtin_types.entry_invalid;
ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
src_ptr_const, src_ptr_volatile, PtrLenUnknown,
src_ptr_align, 0, 0);

View File

@ -700,3 +700,13 @@ test "@intCast to a u0" {
var y: u0 = @intCast(u0, x);
assert(y == 0);
}
test "@bytesToslice on a packed struct" {
const F = packed struct {
a: u8,
};
var b = [1]u8{9};
var f = @bytesToSlice(F, b);
assert(f[0].a == 9);
}