- *(int*)1 incorrectly yielded an assert in LLVM IR lowering #2584.

This commit is contained in:
Christoffer Lerno
2025-11-20 10:36:32 +01:00
parent 2a41fa6281
commit 39694e65c0
3 changed files with 8 additions and 1 deletions

View File

@@ -33,6 +33,7 @@
- Using `defer catch` with a (void), would cause an assertion. #2580
- Fix decl attribute in the wrong place causing an assertion. #2581
- Passing a single value to `@wasm` would ignore the renaming.
- `*(int*)1` incorrectly yielded an assert in LLVM IR lowering #2584.
### Stdlib changes

View File

@@ -2371,7 +2371,7 @@ static inline void llvm_emit_deref(GenContext *c, BEValue *value, Expr *inner, T
llvm_emit_expr(c, value, inner);
llvm_value_rvalue(c, value);
AlignSize alignment = type_abi_alignment(type);
if (safe_mode_enabled())
if (safe_mode_enabled() && !expr_is_const(inner))
{
LLVMValueRef check = LLVMBuildICmp(c->builder, LLVMIntEQ, value->value, llvm_get_zero(c, inner->type), "checknull");
scratch_buffer_clear();

View File

@@ -0,0 +1,6 @@
module main;
fn void main()
{
int x = *(int*)1;
}