Bug 15333 – Assertion failed: (!fd->vthis->csym), function FuncDeclaration_toObjFile, file glue.c, line 1034.

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-14T04:12:00Z
Last change time
2016-10-01T11:45:01Z
Keywords
ice, pull
Assigned to
nobody
Creator
deadalnix

Comments

Comment #0 by deadalnix — 2015-11-14T04:12:43Z
Code : d/semantic/statement.d module d.semantic.statement; struct StatementVisitor { void visit() { Expression iterated; import d.semantic.identifier; SymbolResolver!((e) { new CompileError( iterated.location, e.toString, ); })().resolveInExpression(iterated.location, iterated); } } class CompileError { this(Location , string ) { } } struct Location {} class Expression { Location location; } ************* d/semantic/identifier.d module d.semantic.identifier; alias SymbolResolver(alias handler) = IdentifierResolver!(handler, false); /** * Resolve identifier!(arguments).identifier as type or expression. */ struct TemplateDotIdentifierResolver(alias handler, bool asAlias) { alias Ret = typeof(handler); Ret resolve(TemplateInstanciationDotIdentifier i) { import std.algorithm; i.templateInstanciation.arguments.map!((a) { }); handler(i); } } /** * General entry point to resolve identifiers. */ struct IdentifierResolver(alias handler, bool asAlias) { alias Ret = typeof(handler); import d.semantic.statement; Ret resolveInExpression(Location , Expression) { } Ret visit(TemplateInstanciationDotIdentifier i) { TemplateDotIdentifierResolver!(handler, asAlias)().resolve(i); } } class TemplateInstanciationDotIdentifier { TemplateInstanciation templateInstanciation; } class TemplateInstanciation { uint[] arguments; } *********** util/visitor.d auto dispatch( alias unhandled = { // XXX: Buggy for some reason. // throw new Exception(typeid(t).toString() ~ " is not supported by visitor " ~ typeid(V).toString() ~ " ."); }, V, T)(V visitor, T t) { return dispatchImpl!unhandled(visitor, t); } auto dispatchImpl( alias unhandled, V, T)(V visitor, T t) { alias o = t; import std.traits; import std.typetuple; alias Members = TypeTuple!(__traits(getOverloads, V, "visit")); foreach(visit; Members) { alias parameters = ParameterTypeTuple!visit; alias parameter = parameters; return visitor.visit({ return fastCast!parameter(o); } ()); } } U fastCast(U, T)(T t) { return *cast(U*) t; } **************** Yeah the code is gnarly, this is the best reduction i can have so far. $ dmd -c -oflibd.o d/semantic/identifier.d d/semantic/statement.d -m64 -inline Assertion failed: (!fd->vthis->csym), function FuncDeclaration_toObjFile, file glue.c, line 1034. That makes it impossible to create an optimized build of SDC :'(
Comment #1 by ag0aep6g — 2015-11-14T21:43:56Z
Reduced: identifier.d: ---- module identifier; void map(alias fun)() {} struct IdentifierResolver(alias handler) { void resolve() { map!((a) {}); handler(true); } } ---- statement.d: ---- module statement; import identifier; struct StatementVisitor { void visit() { int location; alias IR = IdentifierResolver!((e) {location = 0;}); } } ---- `dmd -c identifier.d statement.d -inline`: ---- dmd: glue.c:1035: void FuncDeclaration_toObjFile(FuncDeclaration*, bool): Assertion `!fd->vthis->csym' failed. Aborted (core dumped) ----
Comment #2 by k.hara.pg — 2016-03-25T16:49:55Z
Comment #3 by github-bugzilla — 2016-03-26T11:17:31Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0370213f50534dedc27ad4123469b0c80fe26537 fix Issue 15333 - Assertion failed: (!fd->vthis->csym), function FuncDeclaration_toObjFile, file glue.c, line 1034. https://github.com/D-Programming-Language/dmd/commit/403fc69a51b0a71cc9ccebbf1c62983b0ea67059 Merge pull request #5577 from 9rnsr/fix15333 Issue 15333 - Assertion failed: (!fd->vthis->csym), function FuncDeclaration_toObjFile, file glue.c, line 1034
Comment #4 by github-bugzilla — 2016-10-01T11:45:01Z
Commit pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/403fc69a51b0a71cc9ccebbf1c62983b0ea67059 Merge pull request #5577 from 9rnsr/fix15333