```
@nogc:
extern(C) void main() {
foo();
}
void foo() {
bar([1]);
}
void bar(int[]) {}
```
Compiling with `dmd a.d`, it correctly fails with:
```
a.d(8): Error: array literal in `@nogc` function `a.foo` may cause a GC allocation
```
Compiling with `dmd -betterC a.d`, there is no compile error. Instead there is a linker error:
```
/usr/bin/ld: a.o: in function `main':
a.d:(.text.main[main]+0x5): undefined reference to `_D1a3fooFNiZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
```
I don't see a good reason not to have a compile error with `-betterC`. The linker error is harder to diagnose.
Comment #1 by robert.schadek — 2024-12-13T19:31:43Z