Bug 2284 – template is instantiated not properly when instantiated twice with different types
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-08-14T11:20:00Z
Last change time
2015-06-09T05:15:08Z
Keywords
wrong-code
Assigned to
nobody
Creator
2korden
Comments
Comment #0 by 2korden — 2008-08-14T11:20:16Z
I have the following code that does simple type checking:
void check(T)(T t)
{
writefln(T.mangleof);
writefln(typeof(t).mangleof);
writefln(T.sizeof);
writefln(typeof(t).sizeof);
writefln(T.stringof);
writefln(typeof(t).stringof);
}
It should output the same information twice, since is(typeof(t) == T) is true.
Let's run tests:
Test one:
check(42);
Output:
i
i
4
4
int
int
Test two:
check(0.0);
Output:
d
d
8
8
double
double
Ok so far. Test three:
check(42);
check(0.0);
Output:
i
i
4
4
int
int
d
i
8
4
double
int
Whoops! Results got mixed. Looks like typeof(t) returns wrong result now!
Comment #1 by clugdbug — 2009-09-04T03:09:56Z
This was fixed in DMD1.039 when bug 2527 was fixed.