Bug 142 – Assertion failure: '0' on line 610 in file 'template.c'
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-17T15:41:00Z
Last change time
2014-02-15T13:22:18Z
Keywords
ice-on-invalid-code
Assigned to
bugzilla
Creator
lio+bugzilla
Comments
Comment #0 by lio+bugzilla — 2006-05-17T15:41:58Z
// I don't know if the code is supposed to work,
// but I'm trying to convert
// #define A(x) x=2
template A(alias T) {
void A(T) { T=2; }
}
void main()
{
int i;
A(i);
assert(i==2);
}
Comment #1 by fvbommel — 2006-05-17T16:38:40Z
That definitely looks like a compiler bug.
That said, I'm pretty sure that code shouldn't compile anyway.
I think what you're trying to do is probably something like this:
// translation of "#define A(x) x=2".
// Note it can't be translated exactly because the macro doesn't
// have parentheses around it, so code like "A(x) + 2" _will_ do
// something different.
// (i.e. this is actually the translation of "#define A(x) (x=2)")
template A(T) {
void A(out T x) { x=2; }
}
void main()
{
int i;
A(i);
assert(i==2);
}
Comment #2 by smjg — 2006-05-18T07:54:43Z
(In reply to comment #1)
> That definitely looks like a compiler bug.
An assertion failure is a bug by definition.
> That said, I'm pretty sure that code shouldn't compile anyway.
It took me a moment to work it out. But indeed, it shouldn't compile, because the parameter T has no type.