Mercurial > octave
diff libinterp/corefcn/oct-stream.cc @ 25709:02fbbde15308
Fix problems with cset 39fd627b2c5d when octave_idx_type is 64-bit (bug #54405).
* oct-stream.cc (get_size): Avoid using abs() on int64 data types as it returns
incorrect values. Instead, check that numbers are positive before comparing.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 31 Jul 2018 21:03:08 -0700 |
parents | 39fd627b2c5d |
children | 12d4271aed87 |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Tue Jul 31 22:27:59 2018 -0400 +++ b/libinterp/corefcn/oct-stream.cc Tue Jul 31 21:03:08 2018 -0700 @@ -185,9 +185,9 @@ nc = get_size (dnc, who); // Check for overflow. - if (nr != 0 && - abs (nc) > abs (std::numeric_limits<octave_idx_type>::max () / nr)) - ::error ("%s: size too large for Octave's index type", who.c_str ()); + if (nr > 0 && nc > 0 + && nc > std::numeric_limits<octave_idx_type>::max () / nr) + ::error ("%s: size too large for Octave's index type", who.c_str ()); } }