On Thursday, 25 April 2019 at 20:18:28 UTC, Zans wrote:
import std.stdio;

void main()
{
    char[] mychars;
    mychars ~= 'a';
    long index = 0L;
    writeln(mychars[index]);
}

Why would the code above compile perfectly on Linux (Ubuntu 16.04), however it would produce the following error on Windows 10:

source\app.d(8,21): Error: cannot implicitly convert expression index of type long to uint

On both operating systems DMD version is 2.085.0.

The issue here is not Windows vs Linux but 32 bits vs 64 bits.
On 32 bits architectures size_t is defined as uint, long being 64 bits long, conversion from long to uint is a truncating cast which are not allowed implicitely in D. It is unfortunate that the D compiler on Windows is still delivered by default as a 32 bits binary and generating 32 bits code. I think the next release will start to deliver the compiler as 64 bits binary and generating 64 bits code.

Reply via email to