www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - signed / unsigned comparisons

reply h3r3tic <foo bar.baz> writes:
import std.stdio;

void main()
{
	uint a = 100;
	int b = -1;
	
	if (a < b) writefln("a < b");
	else writefln("a >= b");
}


Prints "a < b". Should it really compile without any warnings / errors ?
DMD.118; WinXP
Mar 17 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

h3r3tic schrieb am Thu, 17 Mar 2005 19:46:28 +0100:
 import std.stdio;

 void main()
 {
 	uint a = 100;
 	int b = -1;
 	
 	if (a < b) writefln("a < b");
 	else writefln("a >= b");
 }


 Prints "a < b". Should it really compile without any warnings / errors ?
 DMD.118; WinXP
Your code is legal D. Issuing a warning would be nice. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCOmUL3w+/yD4P9tIRAraqAJsFI4NIraNG1RQWGkMZ72edUFnIHACfbXVQ OetU6JvjGOJmnsG3uP4vLXw= =vyaD -----END PGP SIGNATURE-----
Mar 17 2005