Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 29, 2006 [Issue 271] New: Incorrect constant evaluation of TypeInfo equality comparisons | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=271 Summary: Incorrect constant evaluation of TypeInfo equality comparisons Product: D Version: 0.163 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: critical Priority: P1 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: daiphoenix@lycos.com 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) -- |
August 12, 2006 [Issue 271] Incorrect constant evaluation of TypeInfo equality comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=271 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from bugzilla@digitalmars.com 2006-08-11 19:19 ------- Fixed DMD 0.164 -- |
August 14, 2006 Re: [Issue 271] New: Incorrect constant evaluation of TypeInfo equality comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@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 |
August 14, 2006 Re: [Issue 271] New: Incorrect constant evaluation of TypeInfo equality comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | Thomas Kuehne wrote: > http://dstress.kuehne.cn/run/t/typeid_90_G.d I don't think this test case is correct. You test the type-of a TypeInfo (which is an Object) equality operation vs the type-of an int(which is a primitive type) equality operation. Nothing says that such type-of should be the same (even though I very much think it should). What I do think is not correct is the following (second line) : writefln( typeid(typeof(typeid(int) == typeid(char))) );// int writefln( typeid(typeof(typeid(int) == typeid(int))) );//bool INCORRECT? writefln( typeid(typeof(new Object == new Object)) ); // int writefln( typeid(typeof(typeid(int) != typeid(char))) ); // bool writefln( typeid(typeof(typeid(int) != typeid(int))) ); // bool writefln( typeid(typeof(new Object != new Object)) ); // bool -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D |
August 15, 2006 Re: [Issue 271] New: Incorrect constant evaluation of TypeInfo equality comparisons | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros Attachments: | Bruno Medeiros schrieb am 2006-08-14: > Thomas Kuehne wrote: >> http://dstress.kuehne.cn/run/t/typeid_90_G.d for reference the test was: # # assert(typeid(typeof(typeid(int) == typeid(int))).toString() # == typeid(typeof(args[0].length == args.length)).toString()); # > I don't think this test case is correct. You test the type-of a TypeInfo (which is an Object) equality operation vs the type-of an int(which is a primitive type) equality operation. Nothing says that such type-of should be the same (even though I very much think it should). > > What I do think is not correct is the following (second line) : > > writefln( typeid(typeof(typeid(int) == typeid(char))) );// int > writefln( typeid(typeof(typeid(int) == typeid(int))) );//bool INCORRECT? > writefln( typeid(typeof(new Object == new Object)) ); // int > > writefln( typeid(typeof(typeid(int) != typeid(char))) ); // bool > writefln( typeid(typeof(typeid(int) != typeid(int))) ); // bool > writefln( typeid(typeof(new Object != new Object)) ); // bool See new issue tracker: http://d.puremagic.com/issues/show_bug.cgi?id=288 Thomas |
Copyright © 1999-2021 by the D Language Foundation