Bug 4364 – ICE(class.c) compiling a struct def named 'Object' followed by a class definition
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-06-22T02:30:00Z
Last change time
2012-06-13T02:35:09Z
Keywords
ice, pull
Assigned to
nobody
Creator
pjlbyrne
Comments
Comment #0 by pjlbyrne — 2010-06-22T02:30:54Z
This source file crashes the compiler for me:
--------------------------
struct Object{}
class Game {}
--------------------------
..using dmd2 / windows / VisualD / VS2010Int
Changing 'Object' to any other string makes the crash go away.
Removing the second line ("class Game {}") makes the crash go away.
The assert is:
Assertion failure: 'b->type->ty == Tclass' on line 449 in file 'class.c'
In 'class.c' in the src directory (C:\dmd\src), the assert appears to be on line 446.
Function:
void ClassDeclaration::semantic(Scope *sc)
Code:
// If no base class, and this is not an Object, use Object as base class
if (!baseClass && ident != Id::Object)
{
// BUG: what if Object is redefined in an inner scope?
Type *tbase = new TypeIdentifier(0, Id::Object);
BaseClass *b;
TypeClass *tc;
Type *bt;
if (!object)
{
error("missing or corrupt object.d");
fatal();
}
bt = tbase->semantic(loc, sc)->toBasetype();
b = new BaseClass(bt, PROTpublic);
baseclasses.shift(b);
assert(b->type->ty == Tclass); **** LINE 446 ****
tc = (TypeClass *)(b->type);
baseClass = tc->sym;
assert(!baseClass->isInterfaceDeclaration());
b->base = baseClass;
}
Comment #1 by clugdbug — 2010-09-27T13:35:10Z
Root cause (no patch yet): The special cases for class names need to be moved from the class constructor, into the aggregate constructor.
Comment #2 by clugdbug — 2011-06-23T00:55:38Z
*** Issue 6016 has been marked as a duplicate of this issue. ***