[Issue 271] New: Incorrect constant evaluation of TypeInfo equality comparisons

Thomas Kuehne thomas-dloop at kuehne.cn
Mon Aug 14 04:45:27 PDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail at puremagic.com schrieb am 2006-07-29:
> http://d.puremagic.com/issues/show_bug.cgi?id=271

> Consider:
>
>   writefln( typeid(int) is typeid(int) );  // prints true (Correct)
>   writefln( typeid(int) !is typeid(int) ); // prints false (Correct)
>
>   writefln( typeid(int) == typeid(Object) ); // prints 0      (Correct)
>   writefln( typeid(int) != typeid(Object) ); // prints false! (Correct)
>
>   // prints true (INCORRECT), should be 1, an int:
>   writefln( typeid(int) == typeid(int) ); 
>   // prints true (INCORRECT), should be false:
>   writefln( typeid(int) != typeid(int) ); 
>
>   // prints bool (INCORRECT), should be int 
>   writefln( typeid(typeof(typeid(int) == typeid(int))) ); 
>
> The bug is in the constant folding(evaluation) system: if we the check the asm
> for that code then 1(true) is generated for both == and != calls. Also, the
> following code, which are all runtime evaluations, work correctly:
>
>   auto ti = typeid(int);
>   writefln( ti == ti );          // prints 1     (Correct)
>   writefln( ti != ti );          // prints false (Correct)
>   writefln( ti == typeid(int) ); // prints 1     (Correct)
>   writefln( ti != typeid(int) ); // prints false (Correct)

http://dstress.kuehne.cn/run/t/typeid_90_A.d
http://dstress.kuehne.cn/run/t/typeid_90_B.d
http://dstress.kuehne.cn/run/t/typeid_90_C.d
http://dstress.kuehne.cn/run/t/typeid_90_D.d
http://dstress.kuehne.cn/run/t/typeid_90_E.d
http://dstress.kuehne.cn/run/t/typeid_90_F.d
http://dstress.kuehne.cn/run/t/typeid_90_G.d
http://dstress.kuehne.cn/run/t/typeid_90_H.d
http://dstress.kuehne.cn/run/t/typeid_90_I.d
http://dstress.kuehne.cn/run/t/typeid_90_J.d
http://dstress.kuehne.cn/run/t/typeid_90_K.d

Thomas



-----BEGIN PGP SIGNATURE-----

iD8DBQFE4GqFLK5blCcjpWoRAhuqAKCG1Yt42B4A+KNV5Q8ayzS0SpyiLACeL7HJ
BbMYlPMUE8k094gkIAip2Nc=
=RMHq
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list