Bug 284 – Wrong type of template value parameter

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-08-12T15:15:00Z
Last change time
2014-02-15T13:21:56Z
Assigned to
bugzilla
Creator
oskar.linde

Comments

Comment #0 by oskar.linde — 2006-08-12T15:15:31Z
struct A(int x) { } template B(uint x) { static if (x == 3) static assert(is(A!(3) == A!(x))); } static this() { B!(3); } --- file.d(5): static assert (is(A == A )) is false --- Two instances of A!(3) is created. One with an int value type and the other one with a uint(!) value type. The mangled forms are *__T1AVi3Z1A and *__T1AVk3Z1A respectively.
Comment #1 by thomas-dloop — 2006-08-14T05:20:28Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-08-12: > http://d.puremagic.com/issues/show_bug.cgi?id=284 > struct A(int x) { } > > template B(uint x) { > static if (x == 3) > static assert(is(A!(3) == A!(x))); > } > > static this() { B!(3); } > > --- > > file.d(5): static assert (is(A == A )) is false > > --- > > Two instances of A!(3) is created. One with an int value type and the other one > with a uint(!) value type. The mangled forms are *__T1AVi3Z1A and *__T1AVk3Z1A > respectively. For the mangling aspect see http://d.puremagic.com/issues/show_bug.cgi?id=109 Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE4FsmLK5blCcjpWoRAu3yAJ4ovoL9rE78OwWyhWsKze0rHEdC8ACgnrAa LrfyQ2b7PaBNIOj95s13bSQ= =B//3 -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-08-15T23:42:47Z
The generated template instance is based on the types of the arguments *before* they are implicitly converted to the template parameter type. This is deliberately designed this way so that new template specializations can be added without upsetting existing code. I adjusted the template documentation to clarify this point. Not a bug.