Bug 1409 – Assertion failure: '0' on line 4799 in file 'expression.c'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-08-09T20:20:00Z
Last change time
2014-02-16T15:21:49Z
Keywords
ice-on-invalid-code
Assigned to
bugzilla
Creator
sky
Comments
Comment #0 by sky — 2007-08-09T20:20:09Z
The compiler crashes on the following code (which is, in its current state, invalid - but i can't debug it because of the compiler crash).
I'm sorry that i could not reduce it further.
-----
import std.traits;
private template XParameters(uint n, T...)
{
alias T[0..n] types;
alias T[n..$] curried;
}
private template FuncOpcalls(uint i, alias F, alias parameters)
{
alias Func!(F, parameters.curried.length + i) NewFunc;
NewFunc opCall(parameters.types[0..i] p)
{
return new NewFunc(parameters.curried, p);
}
static if (i < parameters.types.length)
mixin FuncOpcalls!(i+1, F, parameters);
}
class Func(alias F, uint nCurried=0)
{
alias ParameterTypeTuple!(F) paramTypes;
paramTypes[0..nCurried] curriedParameters;
mixin FuncOpcalls!(1, F, XParameters!(paramTypes.length, paramTypes, curriedParameters));
}
void add(int)
{
}
alias Func!(add) c_add;
-----
Compiler output:
-----
Assertion failure: '0' on line 4799 in file 'expression.c'
abnormal program termination
-----
Comment #1 by matti.niemenmaa+dbugzilla — 2007-08-10T09:01:51Z
Reduced:
--
import std.traits;
template XParameters(T...)
{
alias T curried;
}
template FuncOpcalls(alias parameters)
{
alias Func!(parameters.curried + i) NewFunc;
}
class Func(alias F)
{
ParameterTypeTuple!(F) curriedParameters;
mixin FuncOpcalls!(XParameters!(curriedParameters));
}
alias Func!((int){}) c_add;
--
Appears to be a known bug: a comment in expression.c says "BUG: handle other cases like in IdentifierExp::semantic()" just prior to the assert(0) which this hits.
Comment #2 by wbaxter — 2007-10-09T14:51:15Z
Still there as of DMD 1.022. Line number is now 4826, though.