Bug 551 – Modulo operator works with imaginary and complex operands

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P4
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-11-18T06:11:00Z
Last change time
2014-02-15T13:20:31Z
Keywords
accepts-invalid, spec
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Blocks
511

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2006-11-18T06:11:31Z
The spec states that "[t]he modulus operator only works with reals, it is illegal to use it with imaginary or complex operands." yet DMD accepts all of the following: void main() { creal c = 1 + 1i; c %= 2; ireal i = 3i % 2; real r = 3 % 3i; }
Comment #1 by thomas-dloop — 2006-11-25T07:50:54Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-11-18: > http://d.puremagic.com/issues/show_bug.cgi?id=551 > The spec states that "[t]he modulus operator only works with reals, it is > illegal to use it with imaginary or complex operands." yet DMD accepts all of > the following: > > void main() { > creal c = 1 + 1i; > c %= 2; > > ireal i = 3i % 2; > > real r = 3 % 3i; > } Added to DStress as http://dstress.kuehne.cn/nocompile/o/opMod_03_A.d http://dstress.kuehne.cn/nocompile/o/opMod_03_B.d http://dstress.kuehne.cn/nocompile/o/opMod_03_C.d http://dstress.kuehne.cn/nocompile/o/opMod_03_D.d http://dstress.kuehne.cn/nocompile/o/opMod_03_E.d http://dstress.kuehne.cn/nocompile/o/opMod_03_F.d http://dstress.kuehne.cn/nocompile/o/opMod_03_G.d http://dstress.kuehne.cn/nocompile/o/opMod_03_H.d http://dstress.kuehne.cn/nocompile/o/opMod_03_I.d http://dstress.kuehne.cn/nocompile/o/opMod_03_J.d http://dstress.kuehne.cn/nocompile/o/opMod_03_K.d http://dstress.kuehne.cn/nocompile/o/opMod_03_L.d http://dstress.kuehne.cn/nocompile/o/opMod_04_A.d http://dstress.kuehne.cn/nocompile/o/opMod_04_B.d http://dstress.kuehne.cn/nocompile/o/opMod_04_C.d http://dstress.kuehne.cn/nocompile/o/opMod_04_D.d http://dstress.kuehne.cn/nocompile/o/opMod_04_E.d http://dstress.kuehne.cn/nocompile/o/opMod_04_F.d http://dstress.kuehne.cn/nocompile/o/opMod_04_G.d http://dstress.kuehne.cn/nocompile/o/opMod_04_H.d http://dstress.kuehne.cn/nocompile/o/opMod_04_I.d http://dstress.kuehne.cn/nocompile/o/opMod_04_J.d http://dstress.kuehne.cn/nocompile/o/opMod_04_K.d http://dstress.kuehne.cn/nocompile/o/opMod_04_L.d http://dstress.kuehne.cn/nocompile/o/opMod_05_A.d http://dstress.kuehne.cn/nocompile/o/opMod_05_B.d http://dstress.kuehne.cn/nocompile/o/opMod_05_C.d http://dstress.kuehne.cn/nocompile/o/opMod_05_D.d http://dstress.kuehne.cn/nocompile/o/opMod_05_E.d http://dstress.kuehne.cn/nocompile/o/opMod_05_F.d http://dstress.kuehne.cn/nocompile/o/opMod_05_G.d http://dstress.kuehne.cn/nocompile/o/opMod_05_H.d http://dstress.kuehne.cn/nocompile/o/opMod_05_I.d http://dstress.kuehne.cn/nocompile/o/opMod_05_J.d http://dstress.kuehne.cn/nocompile/o/opMod_05_K.d http://dstress.kuehne.cn/nocompile/o/opMod_05_L.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFaFRVLK5blCcjpWoRAi6uAJ4gawAV8p8/Cov+FP7yE564dXwgaACfYre4 s7CWGWuax2UjvILplSwpRB4= =jR0k -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2007-10-04T01:02:47Z
It's supported by the compiler, I'll change the docs.
Comment #3 by braddr — 2007-10-20T04:01:23Z
Docs updated in the 1.022/2.005 release to show that it's legal code.