[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand,
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions |
Date: |
Tue, 9 Oct 2018 13:38:14 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 |
Update of bug #54781 (project octave):
Status: Confirmed => Patch Submitted
_______________________________________________________
Follow-up Comment #5:
Attached is a quick diff that works for me. The error message is different
now, but maybe that is okay?
Previously,
octave:1> x = zeros (2, {1}, 2)
error: octave_base_value::double_value (): wrong type argument 'cell'
error: octave_base_value::int64_value (): wrong type argument 'cell'
error: zeros: dimension arguments must be scalar integers
Now,
octave:2> x = zeros (2, 1.1, 2)
error: zeros: conversion of 1.1 to int64_t value failed
It doesn't mention that the dimension must be a scalar integer. On the other
hand, it identifies the argument that is in error far better.
The diff is trivial
diff -r 2d5f48a39b7e libinterp/corefcn/data.cc
--- a/libinterp/corefcn/data.cc Mon Oct 08 23:04:24 2018 +0200
+++ b/libinterp/corefcn/data.cc Tue Oct 09 10:33:09 2018 -0700
@@ -3931,8 +3931,12 @@ fill_matrix (const octave_value_list& ar
dims.resize (nargin);
for (int i = 0; i < nargin; i++)
- dims(i) = (args(i).isempty ()
- ? 0 : args(i).xidx_type_value ("%s: dimension arguments
must be scalar integers", fcn));
+ {
+ if (args(i).isempty ())
+ dims(i) = 0;
+ else
+ dims(i) = args(i).idx_type_value (true);
+ }
}
break;
}
However, this still doesn't error out if a dimension vector is used.
octave:1> x = zeros ([2, 1.1, 2])
x =
ans(:,:,1) =
0
0
ans(:,:,2) =
0
0
That is a different codepath in the function fill_matrix in data.cc.
(file #45170)
_______________________________________________________
Additional Item Attachment:
File name: intidx.diff Size:0 KB
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?54781>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Kai Torben Ohlhus, 2018/10/04
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, John W. Eaton, 2018/10/04
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Kai Torben Ohlhus, 2018/10/04
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, John W. Eaton, 2018/10/04
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Rik, 2018/10/09
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions,
Rik <=
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Kai Torben Ohlhus, 2018/10/11
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Rik, 2018/10/11
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Rik, 2018/10/11
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Rik, 2018/10/11
- [Octave-bug-tracker] [bug #54781] Matrix creation functions (eye, rand, zeros, ...) allow invalid non-integer dimensions, Kai Torben Ohlhus, 2018/10/12