Lots of bool operations shouldn't compile

Thomas Kuehne thomas-dloop at kuehne.cn
Thu Mar 2 00:20:36 PST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Don Clugston schrieb am 2006-03-01:
> Oskar Linde wrote:
>
>> (But note that the current D bool is (sans bugs) semantically identical 
>> (as far as I can tell) to C99 and C++ bool, who both allows b+=5, et.al.)
>
> I just tried that in MSVC, and you're right. I didn't know that. It's 
> probably a legacy of the pre-bool days when ints or BOOL were used. In 
> practice, I doubt it's really much of a problem. But there doesn't seem 
> to be any rational reason to allow them.
>
> BTW, MSVC accepts
> bool b = true;
> b /= false;  // crashes at run time with a div by zero error
> but gives a warning for
> bool b = true/false; // Can this be constant folded? What the heck does 
> it set it to?
>
> Also accepts b/=6.5;
> Wonder what b/=real.nan does.

That's interresting:

b /= 6.5; // compiles
b = b / 6.5; // fails to compile

Bool is an integer type and thus floats are not implicitly
converted to integral types.

Added to DStress as
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_A.d
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_B.d
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_C.d
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_D.d
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_E.d
http://dstress.kuehne.cn/nocompile/o/opAddAssign_19_F.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_A.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_B.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_C.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_D.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_E.d
http://dstress.kuehne.cn/nocompile/o/opAdd_09_F.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_A.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_B.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_C.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_D.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_E.d
http://dstress.kuehne.cn/nocompile/o/opDivAssign_19_F.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_A.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_B.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_C.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_D.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_E.d
http://dstress.kuehne.cn/nocompile/o/opDiv_14_F.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_A.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_B.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_C.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_D.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_E.d
http://dstress.kuehne.cn/nocompile/o/opMulAssign_19_F.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_A.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_B.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_C.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_D.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_E.d
http://dstress.kuehne.cn/nocompile/o/opMul_09_F.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_A.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_B.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_C.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_D.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_E.d
http://dstress.kuehne.cn/nocompile/o/opSubAssign_19_F.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_A.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_B.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_C.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_D.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_E.d
http://dstress.kuehne.cn/nocompile/o/opSub_09_F.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFEBq+z3w+/yD4P9tIRAu3OAJ45EVLFHn6vpmX4YjKpmEGbpV80PQCeN+Ep
sBYS2snC2tpi10blB5MXRHk=
=mASe
-----END PGP SIGNATURE-----



More information about the Digitalmars-d-bugs mailing list