The DMD backend fails with this code:
import core.stdc.stdlib;
void main() {
auto foo = false && true || abort();
}
This is the error message:
core.exception.AssertError@src/dmd/backend/cod1.d(4027): Assertion failure
----------------
??:? _d_assertp [0x9884d4]
src/dmd/backend/cod1.d:4027 _Z8funccallR11CodeBuilderP4elemjjPjjb [0x8ffd32]
src/dmd/backend/cod1.d:3749 _Z6cdfuncR11CodeBuilderP4elemPj [0x8fef41]
src/dmd/backend/cgcod.d:2738 _Z7codelemR11CodeBuilderP4elemPjj [0x8f510a]
src/dmd/backend/cod2.d:2082 _Z5cdnotR11CodeBuilderP4elemPj [0x90c4d3]
src/dmd/backend/cgcod.d:2738 _Z7codelemR11CodeBuilderP4elemPjj [0x8f510a]
src/dmd/backend/cgcod.d:2868 _Z8scodelemR11CodeBuilderP4elemPjjb [0x8f555c]
src/dmd/backend/cod4.d:709 _Z4cdeqR11CodeBuilderP4elemPj [0x8bec0b]
src/dmd/backend/cgcod.d:2738 _Z7codelemR11CodeBuilderP4elemPjj [0x8f510a]
src/dmd/backend/cgen.d:198 _Z10gencodelemR11CodeBuilderP4elemPjb [0x940c65]
src/dmd/backend/cod3.d:960 _Z14outblkexitcodeR11CodeBuilderP5blockRiPKcPP6Symbolj [0x917fa3]
src/dmd/backend/cgcod.d:1455 _Z8blcodgenP5block [0x8f2efc]
src/dmd/backend/cgcod.d:291 _Z6codgenP6Symbol [0x8f059d]
src/dmd/backend/dout.d:1034 _Z10writefunc2P6Symbol [0x8a457e]
src/dmd/backend/dout.d:853 _Z9writefuncP6Symbol [0x8a3ed6]
src/dmd/glue.d:1199 _Z25FuncDeclaration_toObjFileP15FuncDeclarationb [0x842a4f]
src/dmd/toobj.d:309 _ZN9toObjFile9ToObjFile5visitEP15FuncDeclaration [0x85c1a1]
src/dmd/func.d:2991 _ZN15FuncDeclaration6acceptEP7Visitor [0x767119]
src/dmd/toobj.d:1021 _Z9toObjFileP7Dsymbolb [0x85c108]
src/dmd/glue.d:529 _Z10genObjFileP6Moduleb [0x840b71]
src/dmd/glue.d:122 void dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[], const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool) [0x83f39c]
src/dmd/mars.d:582 int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x64fe08]
src/dmd/mars.d:966 _Dmain [0x651354]
LDC and GDC have no problem with this code so the problem must be related exclusively to the DMD backend, i have no idea what could be causing it someone with backend experience should look into it.
Comment #1 by mail — 2023-05-31T20:27:51Z
The absurd thing is that instead this code compiles and works correctly:
import core.stdc.stdlib;
void main() {
auto foo = (false != true) && true || abort();
}
This looks just like a bad bug in the backend depending on what the code from the frontend
Comment #2 by robert.schadek — 2024-12-13T19:29:20Z