Bug 4709 – ICE(mtype.c): undefined variable in const struct
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-08-22T00:35:00Z
Last change time
2010-11-07T12:27:23Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
bitworld
Comments
Comment #0 by bitworld — 2010-08-22T00:35:47Z
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
*/
Comment #1 by bearophile_hugs — 2010-08-22T06:25:58Z
It's the undefined Bar inside a const struct that causes the problem:
const struct Foo {
Bar* p;
}
void main() {}
Comment #2 by jerminatorster+dbugs — 2010-11-06T17:02:59Z
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.
Comment #3 by clugdbug — 2010-11-06T23:29:56Z
My patch for bug 4434 fixes this.
Comment #4 by bugzilla — 2010-11-07T12:27:23Z
*** This issue has been marked as a duplicate of issue 4434 ***