Hello,

The following code snippet fails to compile on ldc2 (0.12.1), but successfully compiles on dmd 2.064.2 :

struct Particle {
        double x,y,z,w,x2;
        this(double[] arr) {
                x = arr[0]; y = arr[1]; z=arr[2]; w=arr[3];
                x2 = x*x + y*y + z*z;
        }
}

synchronized class SyncArray {
        private Particle[] buf;

        void push(Particle[] arr1) {
                buf.length = arr1.length;
                buf[] = arr1[];
        }

        Particle[] pop() {
                auto _tmp = new Particle[buf.length];
                _tmp[] = buf[];
                buf = null;
                return _tmp;
        }
}

The error message in ldc2 :
test.d(14): Error: cannot implicitly convert expression (arr1[]) of type Particle[] to const(shared(Particle)[]) test.d(19): Error: cannot implicitly convert expression (this.buf[]) of type shared(Particle)[] to const(Particle[])

What am I doing wrong here?

Thanks in advance!
-- Nikhil

P.S. I've been enjoying coding in D a lot -- many thanks to the entire D community!

Reply via email to