size_t index=-1;
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 16 12:39:46 PDT 2016
On Wednesday, March 16, 2016 18:40:56 Laeeth Isharc via Digitalmars-d-learn
wrote:
> should it be a compiler warning to assign a negative literal to
> an unsigned without a cast ?
Maybe? It's a common enough thing to do that I'm willing to bet that Walter
would object, but what you're really looking to do in most cases like that
is to get something like uint.max, in which case it's better to just use the
built-in constant. But I doubt that assigning negative literals to unsigned
variables causes much in the way of bugs.
The bigger problem is comparing signed and unsigned types, and a number of
folks have argued that that should be a warning or error.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list