New Issue: Reduction over instantiated reduce class hits compiler segfault

16462, “ronawho”, “Reduction over instantiated reduce class hits compiler segfault”, “2020-09-24T22:08:35Z”

Trying to do a reduction on an instantiation of a reduction class results in a compiler segfault:

class PlusMinusReduceOp: ReduceScanOp {
  type eltType;
  var sum = true;
  var value: eltType;

  proc identity {
    return 0: eltType;

  proc accumulate(elm) {
    if sum then value += elm;
           else value -= elm;


  proc accumulateOntoState(ref state, elm) {
    if sum then state += elm;
           else state -= elm;

  proc combine(other: borrowed PlusMinusReduceOp) {
    if sum then value += other.value;
           else value -= other.value;
  proc generate() return value;

  proc clone() return new unmanaged PlusMinusReduceOp(eltType=eltType);

config const doSum = true;

var A = [1000, 200, 30, 4];
var plusMinus = new unmanaged PlusMinusReduceOp(eltType=int, sum=doSum);

var sum: int;

// forall reduce with instantiation works
forall elm in A with (plusMinus reduce sum) do
  sum reduce= elm;

// Op reduce with type works (but you can't specify sum=<val>)
sum = PlusMinusReduceOp reduce A;

// Op reduce with instantiation segfaults
sum = plusMinus reduce A;

delete plusMinus;