Deprecation: foreach: loop index implicitly converted from size_t to int

Nicholas Wilson iamthewilsonator at hotmail.com
Fri Jan 18 13:15:05 UTC 2019


On Friday, 18 January 2019 at 12:27:17 UTC, Michael wrote:
> Hello all,
>
> I am getting this deprecation warning when compiling using 
> DMD64 D Compiler v2.084.0 on Linux. I'm a little unsure what 
> the problem is, however, because the code producing these 
> warnings tends to be of the form:
>
>> foreach (int i, ref prop; props)
>
> This, to be, looks like quite the explicit conversion, no? Does 
> it mean I now have to use to!int(i) to convert the type of i in 
> a foreach now?
>
> Thanks,
> Michael.

> foreach (int i, ref prop; props)

All you need to do is

> foreach (i, ref prop; props)

The reason for the deprecation is that if your array props is > 
2GB int can't span the range of indices necessary because it will 
overflow.


More information about the Digitalmars-d-learn mailing list