Stack object size limit error on a static object. #2476

This commit is contained in:
Christoffer Lerno
2025-09-12 17:11:25 +02:00
parent 6aff6d66de
commit e6b10ee00c
3 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -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(

View File

@@ -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;
}