Fix #21054 - No location for array literal sliced from init symbol (#21055)

This commit is contained in:
Dennis 2025-03-22 09:26:49 +01:00 committed by GitHub
parent 14874cffd8
commit 8a96c4745c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -111,3 +111,16 @@ void f() @nogc
DA da = DA.a;
int i = *cast(int*)cast(char[4])['0', '0', '0', '0'];
}
/*
TEST_OUTPUT:
---
fail_compilation/nogc3.d(125): Error: this array literal causes a GC allocation in `@nogc` function `g`
---
*/
// https://github.com/dlang/dmd/issues/21054
void g() @nogc
{
int[] x = (int[2]).init[];
}