3292 – ICE(todt.c) when using a named mixin with an initializer as template alias parameter

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3292 - ICE(todt.c) when using a named mixin with an initializer as template alias parameter
Summary: ICE(todt.c) when using a named mixin with an initializer as template alias pa...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
Reported: 2009年09月03日 13:17 UTC by Koroskin Denis
Modified: 2014年04月18日 09:12 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 Koroskin Denis 2009年09月03日 13:17:58 UTC
template Magic()
{
 void* magic = null;	// remove = null; and bug disappears
}
struct Item
{
 mixin Magic A;
}
struct Foo(alias S)
{
}
void main()
{
 Foo!(Item.A) bar;
}
Assertion failure: 'type' on line 529 in file 'todt.c'
Comment 1 Don 2009年09月16日 00:33:45 UTC
This applies equally to D1.047. It's been present since prehistory (fails identically on DMD0.175).
Comment 2 Don 2009年09月29日 23:52:44 UTC
Another variation gives an ICE in optimize.c. Replace void *magic = null; with
void* magic = cast(void*)(0);
Again, it's because no 'type' is NULL.
Comment 3 Don 2009年10月12日 01:55:37 UTC
This is happening because in this situation, when TemplateMixin::semantic() is called, semanticRun is already 3.
The members get syntax copied:
 // Copy the syntax trees from the TemplateDeclaration
 members = Dsymbol::arraySyntaxCopy(tempdecl->members);
But this destroys their type info, and then since semanticRun is 3, semantic2 never gets run, hence semantic() never gets called on the members ---> they have no type.
I don't think this mixin should be run at all, if it's already done the semantic3 pass. (Note: I have NOT tested this patch against the DMD test suite).
PATCH:
Line 4457, in template.c, TemplateMixin::semantic(Scope *sc) 
 if (!semanticRun)
	semanticRun = 1;
+ if (semanticRun >1) return;
----------------------------
But I'm not sure if this is the correct place to do this check. Should it be being asked to do the semantic at all? It's being called from AliasDeclaration::semantic(), and I'm not sure why:
 if (aliassym)
 {
	if (aliassym->isTemplateInstance()) {
	 aliassym->semantic(sc); // Is this correct??
	}
 return;
 }
Comment 4 Kosmonaut 2009年10月31日 21:24:37 UTC
Fixed in SVN repository: http://www.dsource.org/projects/dmd/changeset/229 
Comment 5 Walter Bright 2009年11月06日 11:30:21 UTC
Fixed dmd 1.051 and 2.036


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