aparapi icon indicating copy to clipboard operation
aparapi copied to clipboard

[BOUNTY $25] Can not directly return an instantiated array.

Open freemo opened this issue 7 years ago • 1 comments

Generating the code for the following will return an exception:

 public class ReturnDoubleArrayNew extends Kernel {

    double[] returnDoubleArrayNew() {
        return new double[1024];
    }

    public void run() {
        returnDoubleArrayNew();
    }
}

However the following work around will compile just fine:

public class ReturnDoubleArrayVar extends Kernel {

    double[] returnDoubleArrayVar() {
        double[] doubles = new double[1024];
        return doubles;
    }

    public void run() {

        returnDoubleArrayVar();
    }
}

freemo avatar Oct 21 '17 16:10 freemo

I wrote a unit test which demonstrates this bug here:

https://github.com/Syncleus/aparapi/blob/master/src/test/java/com/aparapi/runtime/ReturnInstantiatedArrayDirectlyTest.java

freemo avatar Apr 19 '18 17:04 freemo