www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 284] New: Wrong type of template value parameter

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=284

           Summary: Wrong type of template value parameter
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: oskar.linde gmail.com


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.


-- 
Aug 12 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com 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-----
Aug 14 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=284


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





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.


-- 
Aug 15 2006