Bug when offsetting pointers of large structs using ++ and --.

This commit is contained in:
Christoffer Lerno
2025-06-18 10:13:48 +02:00
parent a55f56a88f
commit 01ef53a090
5 changed files with 65 additions and 13 deletions

View File

@@ -2015,7 +2015,7 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa
case TYPE_POINTER:
{
// Use byte here, we don't need a big offset.
LLVMValueRef add = LLVMConstInt(diff < 0 ? llvm_get_type(c, type_ichar) : llvm_get_type(c, type_char), (unsigned long long)diff, diff < 0);
LLVMValueRef add = LLVMConstInt(diff < 0 ? llvm_get_type(c, type_isz) : llvm_get_type(c, type_usz), (unsigned long long)diff, diff < 0);
return llvm_emit_pointer_gep_raw(c, llvm_get_pointee_type(c, type), original->value, add);
}
case ALL_FLOATS: