diff libinterp/corefcn/rand.cc @ 25927:d6581134daaa

Emit an error when utility matrices (zeros, ones, rand, etc.) are given a fractional dimension in a dimension vector (bug #54781). * data.cc (Fones): Add BIST test with a fractional dimension in a dimension vector. * rand.cc (do_rand): Convert dimension vector to Array<octave_idx_type>, not an Array<int>. Call "octave_idx_type_vector_value (true)" to enable input validation. * rand.cc (Frand): Add BIST test with a fractional dimension in a dimension vector. * utils.cc (get_dimensions): Call "octave_idx_type_vector_value (true)" to enable input validation. * ov.cc (int_vector_value, octave_idx_type_vector_value): Change error message when conversion fails to print the original value that failed.
author Rik <rik@octave.org>
date Thu, 11 Oct 2018 15:48:51 -0700
parents 373fe1608f7c
children 90186e77ae39
line wrap: on
line diff
--- a/libinterp/corefcn/rand.cc	Thu Oct 11 14:04:47 2018 -0700
+++ b/libinterp/corefcn/rand.cc	Thu Oct 11 15:48:51 2018 -0700
@@ -207,11 +207,11 @@
           }
         else if (tmp.is_matrix_type ())
           {
-            Array<int> iv;
+            Array<octave_idx_type> iv;
 
             try
               {
-                iv = tmp.int_vector_value (true);
+                iv = tmp.octave_idx_type_vector_value (true);
               }
             catch (octave::execution_exception& e)
               {
@@ -541,6 +541,7 @@
 
 ## Test input validation
 %!error <conversion of 1.1 to.* failed> rand (1, 1.1)
+%!error <dimensions must be .* array of integers> rand ([1, 1.1])
 */
 
 static std::string current_distribution = octave::rand::distribution ();