diff --git a/liboctave/array/Sparse.h b/liboctave/array/Sparse.h --- a/liboctave/array/Sparse.h +++ b/liboctave/array/Sparse.h @@ -68,21 +68,27 @@ protected: octave::refcount count; SparseRep (void) - : d (nullptr), r (nullptr), c (new octave_idx_type [1] {}), + : d (new T [0]), r (new octave_idx_type [0]), + c (new octave_idx_type [1]), nzmx (0), nrows (0), ncols (0), count (1) { } SparseRep (octave_idx_type n) - : d (nullptr), r (nullptr), c (new octave_idx_type [n+1] {}), + : d (new T [0]), r (new octave_idx_type [0]), + c (new octave_idx_type [n+1]), nzmx (0), nrows (n), ncols (n), count (1) - { } + { + std::fill_n (c, n + 1, 0); + } SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz = 0) - : d (nz > 0 ? new T [nz] : nullptr), - r (nz > 0 ? new octave_idx_type [nz] {} : nullptr), - c (new octave_idx_type [nc+1] {}), nzmx (nz), nrows (nr), - ncols (nc), count (1) - { } + : d (new T [nz]), r (new octave_idx_type [nz]), + c (new octave_idx_type [nc+1]), nzmx (nz), nrows (nr), ncols (nc), + count (1) + { + std::fill_n (r, nz, 0); + std::fill_n (c, nc + 1, 0); + } SparseRep (const SparseRep& a) : d (new T [a.nzmx]), r (new octave_idx_type [a.nzmx]),