On 30.10.2011 22:29, bearophile wrote:
I have translated C code similar to:


something foo(int n) {
     int *array = malloc(n * sizeof(int));

     int i;
     for (...) {
         for (i = 0; i<  n; i++, array++) {
             *array = ...;
             *array = ...;
         }
     ...
}


Into D2 code similar to:


something foo(int n) {
     auto array = new int[n];

             *array = ...;

I think the D2 compiler has to catch this bug:

*array = ...;

D arrays aren't pointers. Letting the compiler see them as pointers is 
bug-prone, not tidy, and doesn't help D newbies understand how D represents its 
arrays.

What's New for D 0.177
Dec 9, 2006
New/Changed Features
    Arrays no longer implicitly convert to pointers unless -d is used.

For example, this code:

void main()
{
   int[] x = new int[59];
   int *q = x;
}
compiled on 0.176 and earlier, but not any more. The case involving *arr seems to have just been missed. This is a simple accepts-invalid bug. Not an enhancement request.

Reply via email to