Bug 4254 – ICE(mtype.c): function with const inout parameter
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-05-30T17:02:00Z
Last change time
2010-11-07T13:45:21Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
ellery-newcomer
Comments
Comment #0 by ellery-newcomer — 2010-05-30T17:02:55Z
The code:
void bub(const inout int other) {}
void main() {
bub(1);
}
The result:
dmd: mtype.c:1155: Type* Type::addMod(unsigned int): Assertion `0' failed.
/home/ellery/bin/dmd: line 3: 25241 Aborted (core dumped) /home/ellery/Downloads/dmd2046/linux/bin/dmd $*
dmd 2.046
Comment #1 by clugdbug — 2010-11-01T18:50:04Z
In mtype.c,
Type::addstorageclass() can result in any combination of const, shared, wild.
But not all possible combinations are considered in Type::addmod.
The missing cases are MODconst | MODwild and MODshared | MODconst | MODwild.
Apparently, if both const and wild are present, wild should be ignored.
So, Type::addStorageClass(), line 1180 should have 'else' added, to make MODconst and MODwild mutually exclusive:
if (stc & STCimmutable)
mod = MODimmutable;
else
{ if (stc & (STCconst | STCin))
mod = MODconst;
- if (stc & STCwild)
+ else if (stc & STCwild)
mod = MODwild;
if (stc & STCshared)
mod |= MODshared;
}