4364 – ICE(class.c) compiling a struct def named 'Object' followed by a class definition

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4364 - ICE(class.c) compiling a struct def named 'Object' followed by a class definition
Summary: ICE(class.c) compiling a struct def named 'Object' followed by a class defini...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: ice, pull
: 6016 (view as issue list)
Depends on:
Blocks:
Reported: 2010年06月22日 02:30 UTC by Patrick Byrne
Modified: 2012年06月13日 02:35 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Patrick Byrne 2010年06月22日 02:30:54 UTC
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 Don 2010年09月27日 13:35:10 UTC
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 Don 2011年06月23日 00:55:38 UTC
*** Issue 6016 has been marked as a duplicate of this issue. ***
Comment 3 Kenji Hara 2012年06月01日 04:51:32 UTC
https://github.com/D-Programming-Language/dmd/pull/974 
Comment 4 github-bugzilla 2012年06月12日 15:58:47 UTC
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 Patrick Byrne 2012年06月13日 02:35:09 UTC
Thanks!


AltStyle によって変換されたページ (->オリジナル) /