authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-18 09:49:57-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-18 09:49:57-04:00
logd353d5aef8bfc5c701ab8958751ef74f6704342b
treeebdd1d8f385db5056c903cc74f1ebf3f1f381b1d
parent68c1d059178a36add751e97e11cee004cfdf612e
signaturelock-open Commit is signed but in an unrecognized format.

fix @bytesToSlice on a packed struct

closes #1551

2 files changed, 13 insertions(+), 0 deletions(-)

src/ir.cpp+3
...@@ -18516,6 +18516,9 @@ static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionF...@@ -18516,6 +18516,9 @@ static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionF
18516 src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);18516 src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);
18517 }18517 }
1851818518
18519 if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown)))
18520 return ira->codegen->builtin_types.entry_invalid;
18521
18519 ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,18522 ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
18520 src_ptr_const, src_ptr_volatile, PtrLenUnknown,18523 src_ptr_const, src_ptr_volatile, PtrLenUnknown,
18521 src_ptr_align, 0, 0);18524 src_ptr_align, 0, 0);
test/cases/eval.zig+10
...@@ -700,3 +700,13 @@ test "@intCast to a u0" {...@@ -700,3 +700,13 @@ test "@intCast to a u0" {
700 var y: u0 = @intCast(u0, x);700 var y: u0 = @intCast(u0, x);
701 assert(y == 0);701 assert(y == 0);
702}702}
703
704test "@bytesToslice on a packed struct" {
705 const F = packed struct {
706 a: u8,
707 };
708
709 var b = [1]u8{9};
710 var f = @bytesToSlice(F, b);
711 assert(f[0].a == 9);
712}