diff --git a/releasenotes.md b/releasenotes.md index c8b09395a..45452f692 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -11,6 +11,7 @@ ### Fixes - Add error message if directory with output file name already exists - Regression where nested lambdas would be evaluated twice. +- Compiler crash when using arrays of vectors in lists. #2889 ## 0.7.9 Change list diff --git a/src/compiler/abi/c_abi_x64.c b/src/compiler/abi/c_abi_x64.c index 3366863af..857469c69 100644 --- a/src/compiler/abi/c_abi_x64.c +++ b/src/compiler/abi/c_abi_x64.c @@ -263,7 +263,7 @@ void x64_classify_struct_union(Type *type, ByteSize offset_base, X64Class *curre void x64_classify_array(Type *type, ByteSize offset_base, X64Class *current, X64Class *lo_class, X64Class *hi_class, NamedArgument named_arg) { ByteSize size = type_size(type); - Type *element = type_lowering(type->array.base); + Type *element = lowered_array_element_type(type); ByteSize element_size = type_size(element); // Bigger than 64 bytes => MEM if (size > 64) return; diff --git a/test/test_suite/abi/x64_array_of_vec_in_struct.c3t b/test/test_suite/abi/x64_array_of_vec_in_struct.c3t new file mode 100644 index 000000000..addc0b1fe --- /dev/null +++ b/test/test_suite/abi/x64_array_of_vec_in_struct.c3t @@ -0,0 +1,41 @@ +// #target: linux-x64 +module test; +import std::collections; + +fn void main() +{ + List{int[<2>][2]} test_list; + test_list.tinit(); + + int[<2>][2] input; + + input[0] = {1, 2}; + input[1] = {3, 4}; + + test_list.push(input); + + assert(test_list.contains(input)); + + return; +} + +/* #expect: test.ll + +define void @test.main() #0 { +entry: + %test_list = alloca %"List{int[<2>][2]}", align 8 + %input = alloca [2 x <2 x i32>], align 16 + call void @llvm.memset.p0.i64(ptr align 8 %test_list, i8 0, i64 40, i1 false) + %0 = call ptr @"std.collections.list.List$a2$v2$int$.tinit"(ptr %test_list, i64 16) + store <2 x i32> zeroinitializer, ptr %input, align 16 + %ptradd = getelementptr inbounds i8, ptr %input, i64 8 + store <2 x i32> zeroinitializer, ptr %ptradd, align 8 + store <2 x i32> , ptr %input, align 16 + %ptradd1 = getelementptr inbounds i8, ptr %input, i64 8 + store <2 x i32> , ptr %ptradd1, align 8 + %lo = load i64, ptr %input, align 16 + %ptradd2 = getelementptr inbounds i8, ptr %input, i64 8 + %hi = load i64, ptr %ptradd2, align 8 + call void @"std.collections.list.List$a2$v2$int$.push"(ptr %test_list, i64 %lo, i64 %hi) #2 + ret void +}