Dynamic arrays allocation size

Ali Çehreli acehreli at yahoo.com
Mon Mar 25 22:38:40 PDT 2013


On 03/25/2013 07:23 PM, "Luís Marques" <luismarques at gmail.com>" wrote:
 > Hi,
 >
 > There seems to be a bug allocating large dynamic arrays in a 64-bit
 > aware dmd (v2.062). Apparently, the size argument makes a trip through
 > 32-bit ptrdiff_t land or something like that:
 >
 > unittest
 > {
 > immutable size_t size = 3 * 1024 * 1024 * 1024;

On a tangent, despite appearances, the type of the right-hand side is 
int with the value of -1073741824. It is according to the arithmetic 
conversion rules:

   http://dlang.org/type.html

Ali



More information about the Digitalmars-d mailing list