Integer conversions too pedantic in 64-bit

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Feb 14 16:30:09 PST 2011


Here's something I've noticed (x86 code):

void main()
{
    ulong size = 2;
    int[] arr = new int[](size);
}

This will error with:
sizetTest.d(8): Error: cannot implicitly convert expression (size) of
type ulong to uint

size_t is aliased to uint since I'm running 32bit.

I'm really not experienced at all with 64bit, so I don't know if it's
good to use uint explicitly (my hunch is that it's not good). uint as
the array size wouldn't even compile in 64bit, right?

If I'm correct, wouldn't it be better if the error showed that it
expects size_t which might be aliased to whatever type for a
particular machine?


More information about the Digitalmars-d mailing list