www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - AA's indexed by doubles bug

reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
int main() {
    int[double] x;
    double d=22;
    x[d] = 44;
    assert( x[d] == 44 ); //fails
    return 0;
}
Mar 26 2005
parent reply =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= writes:
-----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



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCRawB3w+/yD4P9tIRAusKAJ95bfpnJY5PoDZIKNC535VMzIv7KQCgihde
/4vmbhyQAF+b73zKpBGgaqI=
=wd3P
-----END PGP SIGNATURE-----
Mar 26 2005
parent Dave <Dave_member pathlink.com> writes:
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
Mar 28 2005