changeset 10577:87f879cf48fd

don't alter arg values in call to abs or sign for integer values
author John W. Eaton <jwe@octave.org>
date Tue, 27 Apr 2010 00:52:28 -0400
parents 384c514bbae2
children cb0883127251
files liboctave/ChangeLog liboctave/intNDArray.cc
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Mon Apr 26 23:14:24 2010 +0200
+++ b/liboctave/ChangeLog	Tue Apr 27 00:52:28 2010 -0400
@@ -1,3 +1,8 @@
+2010-04-27  John W. Eaton  <jwe@octave.org>
+
+	* intNDArray.cc (intNDArray<T>::abs, intNDArray<T>::signum):
+	Create new vector for return values.  Fixes bug #29685.
+
 2010-04-23  Jaroslav Hajek  <highegg@gmail.com>
 
 	* Sparse.cc (Sparse<T>::assign): Fix typos.
--- a/liboctave/intNDArray.cc	Mon Apr 26 23:14:24 2010 +0200
+++ b/liboctave/intNDArray.cc	Tue Apr 27 00:52:28 2010 -0400
@@ -174,7 +174,7 @@
 intNDArray<T>::abs (void) const
 {
   octave_idx_type nel = this->nelem ();
-  intNDArray<T> ret (*this);
+  intNDArray<T> ret (this->dims ());
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -190,7 +190,7 @@
 intNDArray<T>::signum (void) const
 {
   octave_idx_type nel = this->nelem ();
-  intNDArray<T> ret (*this);
+  intNDArray<T> ret (this->dims ());
 
   for (octave_idx_type i = 0; i < nel; i++)
     {