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. ***
Comment #3 by k.hara.pg — 2012-06-01T04:51:32Z
Comment #4 by github-bugzilla — 2012-06-12T15:58:47Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/fbe7a1c9e107c9eb4bba8f27c87f248b7e6889ae fix Issue 4364 - ICE(class.c) compiling a struct def named 'Object' followed by a class definition Stop looking for 'Object' type. https://github.com/D-Programming-Language/dmd/commit/1c618b0b1eeee336e442767037cf86a103446765 Merge pull request #974 from 9rnsr/fix4364 Issue 4364 - ICE(class.c) compiling a struct def named 'Object' followed by a class definition
Comment #5 by pjlbyrne — 2012-06-13T02:35:09Z
Thanks!