www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - *, /, and .im of complex numbers is wrong at compile time.

reply Don Clugston <dac nospam.com.au> writes:
DMD 0.138, Windows.
It works for add + subtract, but returns 0 (with the correct sign) 
whenever * or / is involved (BUG 1-4).
I think the root cause lies with ireal.im, which behaves _very_ oddly.
(BUG 5 and BUG 6) Looks like it's grabbing the wrong part of the syntax 
tree.

BUG 1-------------------------------
static assert(1i * 1i == -1);
bug.d(1): static assert  (-0 == -1) is false

BUG 2-------------------------------
static assert(3.0i /1.0i == 3);
bug.d(1): static assert  (0 == 3) is false

BUG 3-------------------------------
static assert(3.0i *2 == 6i);
bug.d(1): static assert  (0i == 6i) is false

BUG 4-------------------------------
static assert((2.0i).im == 2.0);
bug.d(1): static assert  (2i == 2) is false

BUG 5------------------------------
static assert((3+2.0i).im == 2.0);
bug.d(1): static assert  (3 == 2) is false
Nov 08 2005
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don Clugston schrieb am 2005-11-08:
 DMD 0.138, Windows.
 It works for add + subtract, but returns 0 (with the correct sign) 
 whenever * or / is involved (BUG 1-4).
 I think the root cause lies with ireal.im, which behaves _very_ oddly.
 (BUG 5 and BUG 6) Looks like it's grabbing the wrong part of the syntax 
 tree.

 BUG 1-------------------------------
 static assert(1i * 1i == -1);
 bug.d(1): static assert  (-0 == -1) is false

 BUG 2-------------------------------
 static assert(3.0i /1.0i == 3);
 bug.d(1): static assert  (0 == 3) is false

 BUG 3-------------------------------
 static assert(3.0i *2 == 6i);
 bug.d(1): static assert  (0i == 6i) is false

 BUG 4-------------------------------
 static assert((2.0i).im == 2.0);
 bug.d(1): static assert  (2i == 2) is false

 BUG 5------------------------------
 static assert((3+2.0i).im == 2.0);
 bug.d(1): static assert  (3 == 2) is false
Added to DStress as http://dstress.kuehne.cn/run/c/cdouble_02_A.d http://dstress.kuehne.cn/run/c/cdouble_02_B.d http://dstress.kuehne.cn/run/c/cdouble_02_C.d http://dstress.kuehne.cn/run/c/cfloat_03_A.d http://dstress.kuehne.cn/run/c/cfloat_03_B.d http://dstress.kuehne.cn/run/c/cfloat_03_C.d http://dstress.kuehne.cn/run/c/creal_27_A.d http://dstress.kuehne.cn/run/c/creal_27_B.d http://dstress.kuehne.cn/run/c/creal_27_C.d http://dstress.kuehne.cn/run/o/opAdd_07_A.d http://dstress.kuehne.cn/run/o/opAdd_07_B.d http://dstress.kuehne.cn/run/o/opDiv_12_A.d http://dstress.kuehne.cn/run/o/opDiv_12_B.d http://dstress.kuehne.cn/run/o/opMul_08_A.d http://dstress.kuehne.cn/run/o/opMul_08_B.d http://dstress.kuehne.cn/run/o/opMul_08_C.d http://dstress.kuehne.cn/run/o/opMul_08_D.d http://dstress.kuehne.cn/run/o/opMul_08_E.d http://dstress.kuehne.cn/run/o/opSub_07_A.d http://dstress.kuehne.cn/run/o/opSub_07_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDdjRB3w+/yD4P9tIRAnRlAKCHxtg0yuvj9cdfkl6RWUMGveWLaQCfV6sU MTRrBWGpX0X5ajleOjSEanQ= =i5BI -----END PGP SIGNATURE-----
Nov 12 2005