aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-06-07 00:10:39 +0100
committergingerBill <bill@gingerbill.org>2023-06-07 00:10:39 +0100
commit2bc5e0ebd71f1337cf5c3820cb4b623a29e90fbe (patch)
treedd396912c18c8ef663ef041ea905a6647a5a2874 /src/llvm_backend_expr.cpp
parentca6cef9a7ddb1e3714cc9f5a43053bc7a240b115 (diff)
Fix non-constant compound literals of slices
Diffstat (limited to 'src/llvm_backend_expr.cpp')
-rw-r--r--src/llvm_backend_expr.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp
index b2adc254d..f95e351ce 100644
--- a/src/llvm_backend_expr.cpp
+++ b/src/llvm_backend_expr.cpp
@@ -4230,11 +4230,12 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) {
lbValue count = {};
count.type = t_int;
+ unsigned len_index = lb_convert_struct_index(p->module, type, 1);
if (lb_is_const(slice)) {
- unsigned indices[1] = {1};
+ unsigned indices[1] = {len_index};
count.value = LLVMConstExtractValue(slice.value, indices, gb_count_of(indices));
} else {
- count.value = LLVMBuildExtractValue(p->builder, slice.value, 1, "");
+ count.value = LLVMBuildExtractValue(p->builder, slice.value, len_index, "");
}
lb_fill_slice(p, v, data, count);
}