| ... | ... | @@ -14982,12 +14982,16 @@ static Stage1AirInst *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, Stage1ZirI |
| 14982 | 14982 | case ConstPtrSpecialSubArray: |
| 14983 | 14983 | case ConstPtrSpecialBaseArray: |
| 14984 | 14984 | { |
| 14985 | uint64_t array_len = ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len; |
| 14986 | if (ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.sentinel != nullptr) { |
| 14987 | array_len += 1; |
| 14988 | } |
| 14985 | 14989 | size_t offset = ptr_field->data.x_ptr.data.base_array.elem_index; |
| 14986 | 14990 | uint64_t new_index = offset + index; |
| 14987 | 14991 | if (ptr_field->data.x_ptr.data.base_array.array_val->data.x_array.special != |
| 14988 | 14992 | ConstArraySpecialBuf) |
| 14989 | 14993 | { |
| 14990 | | if (new_index >= ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len) { |
| 14994 | if (new_index >= array_len) { |
| 14991 | 14995 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, buf_sprintf("out of bounds slice")); |
| 14992 | 14996 | return ira->codegen->invalid_inst_gen; |
| 14993 | 14997 | } |