| ... | @@ -15341,9 +15341,14 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, | ... | @@ -15341,9 +15341,14 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 15341 | ZigType *array_type = actual_type->data.pointer.child_type; | 15341 | ZigType *array_type = actual_type->data.pointer.child_type; |
| 15342 | bool const_ok = (slice_ptr_type->data.pointer.is_const || array_type->data.array.len == 0 | 15342 | bool const_ok = (slice_ptr_type->data.pointer.is_const || array_type->data.array.len == 0 |
| 15343 | || !actual_type->data.pointer.is_const); | 15343 | || !actual_type->data.pointer.is_const); |
| | 15344 | |
| 15344 | if (const_ok && types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type, | 15345 | if (const_ok && types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type, |
| 15345 | array_type->data.array.child_type, source_node, | 15346 | array_type->data.array.child_type, source_node, |
| 15346 | !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk) | 15347 | !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk && |
| | 15348 | (slice_ptr_type->data.pointer.sentinel == nullptr || |
| | 15349 | (array_type->data.array.sentinel != nullptr && |
| | 15350 | const_values_equal(ira->codegen, array_type->data.array.sentinel, |
| | 15351 | slice_ptr_type->data.pointer.sentinel)))) |
| 15347 | { | 15352 | { |
| 15348 | // If the pointers both have ABI align, it works. | 15353 | // If the pointers both have ABI align, it works. |
| 15349 | // Or if the array length is 0, alignment doesn't matter. | 15354 | // Or if the array length is 0, alignment doesn't matter. |