I got the issue mentionned in the title, with the following piece of code (I didn't succeed in reducing it further).
auto dispatch(
alias unhandled = {
}, V, T
)(V visitor, ref T t) {
return t;
}
class Type {
}
class BuiltinType(T) : Type {
}
Type getPromotedType(Type t2) {
class T2Handler(T) {
Type visit(Type t) {
return this.dispatch!(t => new BuiltinType!T)(t);
}
}
class T1Handler {
Type visit(Type t) {
return (t => handleBuiltinType!int)(t);
}
auto handleBuiltinType(T)() {
return (new T2Handler!T).visit(t2);
}
Type visit() {
return handleBuiltinType!uint;
}
}
return (new T1Handler).visit;
}
I have no clue what precisely cause the error.
Comment #1 by bugzilla — 2012-07-25T11:43:19Z
It's related to failing to detect that one is calling a nested function from a context where the context pointer to that nested function cannot be generated.
Comment #2 by deadalnix — 2012-07-25T11:51:09Z
(In reply to comment #1)
> It's related to failing to detect that one is calling a nested function from a
> context where the context pointer to that nested function cannot be generated.
I don't think so. I solved the issue in the real codebase by using
(Type t){ return new BuiltinType!T(); }
instead of
t => new BuiltinType!T()
And the same for all reduced delegate syntax. It seems that the problem shows up when the delegate is templated (necessary but not sufficient).
I discovered that later, so it isn't in the original bug report.
Comment #3 by bugzilla — 2012-07-25T13:02:54Z
Knowing that it is related to the template version is helpful.
Comment #4 by clugdbug — 2012-11-13T11:37:38Z
probably a duplicate of one of the other ICE(toir.c) bugs. bug4504, bug5902, bug6426, etc.