diff --git a/releasenotes.md b/releasenotes.md index 68ad582d3..efe1dd70a 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -20,6 +20,7 @@ - int val = some_int + some_distinct_inline_int errors that int cannot be cast to DistinctInt #2468 - Compiler hang with unaligned load-store pair. #2470 - `??` with void results on both sides cause a compiler crash #2472. +- Stack object size limit error on a static object. #2476 ### Stdlib changes - Added generic `InterfaceList` to store a list of values that implement a specific interface diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 2ce4c40ba..e4875a323 100755 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -4817,7 +4817,7 @@ bool sema_analyse_var_decl(SemaContext *context, Decl *decl, bool local, bool *c { if (!sema_set_alloca_alignment(context, decl->type, &decl->alignment)) return false; } - if (decl->var.kind == VARDECL_LOCAL && type_size(decl->type) > compiler.build.max_stack_object_size * 1024) + if (decl->var.kind == VARDECL_LOCAL && !is_static && type_size(decl->type) > compiler.build.max_stack_object_size * 1024) { size_t size = type_size(decl->type); RETURN_SEMA_ERROR( diff --git a/test/test_suite/statements/bit_static_local.c3 b/test/test_suite/statements/bit_static_local.c3 new file mode 100644 index 000000000..9f93573c5 --- /dev/null +++ b/test/test_suite/statements/bit_static_local.c3 @@ -0,0 +1,8 @@ +module test; + +fn int main() +{ + static char[(1024 * mem::KB) + 1] a; + tlocal char[(1024 * mem::KB) + 1] b; + return 0; +} \ No newline at end of file