- Assert triggered when casting from int[2] to uint[2] #2115

This commit is contained in:
Christoffer Lerno
2025-05-01 18:23:48 +02:00
parent f0d2b0eff0
commit 11bb8b49da
3 changed files with 32 additions and 2 deletions

View File

@@ -2,7 +2,8 @@
## 0.7.2 Change list
No changes yet
### Fixes
- Assert triggered when casting from `int[2]` to `uint[2]` #2115
## 0.7.1 Change list

View File

@@ -2199,7 +2199,7 @@ static void cast_arr_to_vec(Expr *expr, Type *to_type)
static void cast_arr_to_arr(Expr *expr, Type *to_type)
{
ASSERT(type_size(to_type) == type_size(expr->type));
expr->type = to_type;
expr_rewrite_recast(expr, to_type);
}
static void cast_anyfault_to_bool(Expr *expr, Type *to_type)

View File

@@ -0,0 +1,29 @@
// #target: macos-x64
module test;
fn void main()
{
uint[2] v;
foo(v);
}
fn void foo(int[2] v) {}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%v = alloca [2 x i32], align 4
store i32 0, ptr %v, align 4
%ptradd = getelementptr inbounds i8, ptr %v, i64 4
store i32 0, ptr %ptradd, align 4
%0 = load i64, ptr %v, align 4
call void @test.foo(i64 %0)
ret void
}
define void @test.foo(i64 %0) #0 {
entry:
%v = alloca [2 x i32], align 4
store i64 %0, ptr %v, align 4
ret void
}