Thread overview | |||||
---|---|---|---|---|---|
|
March 26, 2005 AA's indexed by doubles bug | ||||
---|---|---|---|---|
| ||||
int main() { int[double] x; double d=22; x[d] = 44; assert( x[d] == 44 ); //fails return 0; } |
March 26, 2005 Re: AA's indexed by doubles bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle Attachments: | Ben Hinkle wrote: | int main() { | int[double] x; | double d=22; | x[d] = 44; | assert( x[d] == 44 ); //fails | return 0; | } Added to DStress as http://dstress.kuehne.cn/run/associative_array_08.d http://dstress.kuehne.cn/run/associative_array_09.d http://dstress.kuehne.cn/run/associative_array_10.d http://dstress.kuehne.cn/run/associative_array_11.d http://dstress.kuehne.cn/run/associative_array_12.d http://dstress.kuehne.cn/run/associative_array_13.d http://dstress.kuehne.cn/run/associative_array_14.d http://dstress.kuehne.cn/run/associative_array_15.d http://dstress.kuehne.cn/run/associative_array_16.d http://dstress.kuehne.cn/run/associative_array_17.d Thomas |
March 28, 2005 Re: AA's indexed by doubles bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | In article <d24a39$3ic$1@digitaldaemon.com>, =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= says... > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >Ben Hinkle wrote: > >| int main() { >| int[double] x; >| double d=22; >| x[d] = 44; >| assert( x[d] == 44 ); //fails >| return 0; >| } > >Added to DStress as http://dstress.kuehne.cn/run/associative_array_08.d http://dstress.kuehne.cn/run/associative_array_09.d http://dstress.kuehne.cn/run/associative_array_10.d http://dstress.kuehne.cn/run/associative_array_11.d http://dstress.kuehne.cn/run/associative_array_12.d http://dstress.kuehne.cn/run/associative_array_13.d http://dstress.kuehne.cn/run/associative_array_14.d http://dstress.kuehne.cn/run/associative_array_15.d http://dstress.kuehne.cn/run/associative_array_16.d http://dstress.kuehne.cn/run/associative_array_17.d > >Thomas > In the hope of saving a little time tracking these down, the problem looks like it is in the return statement for the relevant _compare(...) methods for each of those types in phobos/std/typeinfo/ti_<type>.d. For example, in phobos/std/typeinfo/ti_double.d: | static int _compare(double d1, double d2) | { | if (d1 !<>= d2) // if either are NaN | { | if (isnan(d1)) | { if (isnan(d2)) | return 0; | return -1; | } | return 1; | } |// return (d1 < d2) ? -1 : 1; // <-- problem here | return (d1 < d2) ? -1 : (d1 > d2) ? 1 : 0; | } - Dave |
Copyright © 1999-2021 by the D Language Foundation