size_t index=-1;
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Mar 16 14:49:05 PDT 2016
On 3/16/16 4:55 PM, Mathias Lang wrote:
> On Wednesday, 16 March 2016 at 20:11:41 UTC, Steven Schveighoffer wrote:
>> 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.
>
> We can change it, and we should. But it should be deprecated properly,
> and we should put in place enough candy to make it viable (See
> http://forum.dlang.org/post/vbeohujwdsoqfgwqgasa@forum.dlang.org ).
No, please don't. Assigning a signed value to an unsigned (and vice
versa) is very useful, and there is no good reason to break this.
-Steve
More information about the Digitalmars-d-learn
mailing list