From 5390ca62504ea9ff2c70d151f4fd2e72a01a5c76 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 20 Jan 2026 13:02:14 +0100 Subject: [PATCH] - Eager evaluation of macro arguments would break inferred arrays on some platforms. #2771. --- releasenotes.md | 1 + src/compiler/llvm_codegen_expr.c | 1 + src/compiler/sema_decls.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/releasenotes.md b/releasenotes.md index e5f7f0b02..f33e49a9d 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -85,6 +85,7 @@ - Comparing an uint and int[<4>] was incorrectly assumed to be uint compared to int, causing a crash instead of an error. #2771 - When an `int[*][6]` was given too few values, the compiler would assert instead of giving an error. #2771 - Inferring length from a slice was accidentally not an error. +- Eager evaluation of macro arguments would break inferred arrays on some platforms. #2771. ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index cf2390f1f..326b776e7 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -6278,6 +6278,7 @@ static inline void llvm_emit_macro_block(GenContext *c, BEValue *be_value, Expr BEValue value; c->debug.block_stack = old_inline_location; llvm_emit_expr(c, &value, init_expr); + if (!val->alignment) val->alignment = type_abi_alignment(val->type); if (llvm_value_is_addr(&value) || val->var.is_written || val->var.is_addr || llvm_use_accurate_debug_info(c)) { c->debug.block_stack = inline_location; diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 67ffe4a01..33a5c92d9 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -1451,7 +1451,7 @@ static inline bool sema_analyse_signature(SemaContext *context, Signature *sig, { if (!sema_deep_resolve_function_ptr(context, type_info)) return false; param->type = type_info->type; - if (!sema_set_alignment(context, param->type, ¶m->alignment, true)) return false; + if (!is_macro && !sema_set_alignment(context, param->type, ¶m->alignment, true)) return false; } if (param->var.init_expr)