The following code will lead DMD terminated abnormally. After getting rid of the "const" in "const struct SB_uint8", this termination problem is missing. =================== import std.stdio; /* struct D_Shift { ushort symbol; ubyte shift_kind; ubyte op_assoc; int op_priority; int term_priority; int action_index; } */ // the bug is here const struct SB_uint8 { D_Shift **shift; ubyte *[2] scanner_block; } int main(string[] args) { return 0; } /* Z:\>dmd main.d main.d(17): Error: identifier 'D_Shift' is not defined main.d(17): Error: D_Shift is used as a type main.d(20): Error: identifier 'D_Shift' is not defined main.d(20): Error: D_Shift is used as a type Assertion failure: 'tn->mod & MODimmutable || tn->mod & MODconst' on line 875 in file 'mtype.c' abnormal program termination */
It's the undefined Bar inside a const struct that causes the problem: const struct Foo { Bar* p; } void main() {}
I get this same bug using 'alias const', eg: alias int ITEMIDLIST_ABSOLUTE; alias const ITEMIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE; Gives the same compile error: Assertion failure: 'tn->mod & MODimmutable || tn->mod & MODconst' on line 875 in file 'mtype.c' This also happens if you use a struct: struct ITEMIDLIST_ABSOLUTE { int foo; } alias const ITEMIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE; But *not* if you use a primitive type directly: alias const int *PCIDLIST_ABSOLUTE; Removing the const also avoids the error.
My patch for bug 4434 fixes this.
*** This issue has been marked as a duplicate of issue 4434 ***