size_t index=-1;

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 13:11:41 PDT 2016


On 3/16/16 2:40 PM, Laeeth Isharc wrote:
> should it be a compiler warning to assign a negative literal to an
> unsigned without a cast ?

Why? They implicitly convert.

int  x = -1;
uint y = x;

I don't see a difference between this and your code. And we can't change 
this behavior of the second line, too much arguably valid code would break.

-Steve


More information about the Digitalmars-d-learn mailing list