to:
stan::agrad::vari* DUMMY_VARI_PTR__ = new vari(std::numeric_limits<double>::quiet_NaN(),false);
stan::agrad::var DUMMY_VAR__ = var(DUMMY_VARI_PTR__);
That call to new() is using the arena based allocator. There is no leak by not deleting it. It avoids the problem of having DUMMY_VARI__ trigger the std::logic_error on automatic destruction.
As far as I can tell, we can't push the allocation of the vari into the class somewhere because it will be "deallocated" when the gradient is calculated.
Anyone see any problems with this change?
Daniel