From a913f21c4571910fbfef5a942003775697b21c01 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 31 Dec 2024 16:45:10 +0100 Subject: [PATCH] Fix issue with compiling a constant struct containing a string array in a local context. --- releasenotes.md | 1 + src/compiler/llvm_codegen_expr.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/releasenotes.md b/releasenotes.md index bd4e6ba2e..a83ae6fa7 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -35,6 +35,7 @@ - Add check in formatter printing "%c". - Fix bug where `!!` and `!` was not recognized to jump out of the current scope. - Fix bug when including compile time parameters in trailing body more than once. +- Fix issue with compiling a constant struct containing a string array in a local context. ### Stdlib changes - Increase BitWriter.write_bits limit up to 32 bits. diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 04eeae929..61629ac31 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -7251,7 +7251,10 @@ static void llvm_emit_default_arg(GenContext *c, BEValue *value, Expr *expr) void llvm_emit_expr_global_value(GenContext *c, BEValue *value, Expr *expr) { sema_cast_const(expr); + LLVMBuilderRef b = c->builder; + c->builder = c->global_builder; llvm_emit_expr(c, value, expr); + c->builder = b; ASSERT0(!llvm_value_is_addr(value)); }