--- final class C { void foo() { S[] s; if (s[$-1] == S.init) {} } } struct S { int[] a; int b; } void bar() { C.init.foo(); } --- compiling with "dmd -O -inline" yields "Internal error: tk.c 266" Original occurrence: https://github.com/rejectedsoftware/diet-ng/issues/15
Appears on at least DMD 2.070.0 up to DMD 2.073.0.
Nowadays it's dmd: dmd/backend/dvec.d:299: Assertion `v && (b < vec_numbits(v))' failed.
Appears to have been fixed in 2.084.0
The bug is still there. It "disappeared" for a time because asserts were turned off in the backend, obviously that was a bad idea.
Simpler test case: struct S { int[] a; int b; } void foo() { S[] s; if (s[$-1] == S.init) {} } void bar() { foo(); }
@WalterBright created dlang/dmd pull request #12403 "fix Issue 17146 - Internal error: tk.c 266 with -O -inline" fixing this issue: - fix Issue 17146 - Internal error: tk.c 266 with -O -inline https://github.com/dlang/dmd/pull/12403
dlang/dmd pull request #12403 "fix Issue 17146 - Internal error: tk.c 266 with -O -inline" was merged into master: - 19c8234b8e3e81584824e50149729965e4eb4286 by Walter Bright: fix Issue 17146 - Internal error: tk.c 266 with -O -inline https://github.com/dlang/dmd/pull/12403