D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2284 - template is instantiated not properly when instantiated twice with different types
Summary: template is instantiated not properly when instantiated twice with different ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-08-14 11:20 UTC by Koroskin Denis
Modified: 2015-06-09 05:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Koroskin Denis 2008-08-14 11:20:16 UTC
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 Don 2009-09-04 03:09:56 UTC
This was fixed in DMD1.039 when bug 2527 was fixed.