diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-03-06 17:19:45 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-03-06 17:19:45 -0500 |
| commit | 44ae891bd79cc8b2f9040a39c176317ebf4a4ef8 (patch) | |
| tree | 3d4586803b1549dc64a8ad977ba39f03d4b74b68 /src/ir.cpp | |
| parent | cc0f660ad245b0482981b8dcc2b200c7d68b943d (diff) | |
| download | zig-44ae891bd79cc8b2f9040a39c176317ebf4a4ef8.tar.gz zig-44ae891bd79cc8b2f9040a39c176317ebf4a4ef8.zip | |
fix assertion when taking slice of zero-length array
closes #788
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 251c55df4f..61f04fef3d 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15821,9 +15821,13 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio TypeTableEntry *return_type; if (array_type->id == TypeTableEntryIdArray) { + uint32_t byte_alignment = ptr_type->data.pointer.alignment; + if (array_type->data.array.len == 0 && byte_alignment == 0) { + byte_alignment = get_abi_alignment(ira->codegen, array_type->data.array.child_type); + } TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type, ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, - ptr_type->data.pointer.alignment, 0, 0); + byte_alignment, 0, 0); return_type = get_slice_type(ira->codegen, slice_ptr_type); } else if (array_type->id == TypeTableEntryIdPointer) { TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type, |
