foreach counter now must be size_t ?

Rubn where at is.this
Tue Feb 5 23:57:38 UTC 2019


On Tuesday, 5 February 2019 at 23:04:16 UTC, Walter Bright wrote:
> On 2/5/2019 1:14 PM, Rubn wrote:
>> WHAT. WHAT. Where do you see an assignment from size_t to int 
>> here?
>> 
>> int[] arr = someRandomArray();
>> for( int i = 0; i < arr.length; ++i ) {
>>     dg( i, arr[i] );
>> }
>> 
>> ???
>
> The ++i overflows and the loop never terminates.

In case you forgot what you said:

> It's irrelevant, as the semantics of the language have to be 
> sound across the uses it supports.

This change to not allow int goes against the semantics of the 
language.


More information about the Digitalmars-d mailing list