# HG changeset patch # User John W. Eaton # Date 1388800533 18000 # Node ID cda4bd2fd0c09e1a3287cf990d991488c045404b # Parent 775e7874b38dd9dfcec2d10fe053f7a3cea66d2c fix null matrix assignment to indexed integer and logical values (bug #35921) * op-int.h (OCTAVE_INSTALL_INT_NULL_ASSIGN_OPS): Install asignment conversions for null matrix assignments to scalars. * op-b-b.cc (install_b_b_ops): Likewise. * null-assign.tst: New test. diff -r 775e7874b38d -r cda4bd2fd0c0 libinterp/operators/op-b-b.cc --- a/libinterp/operators/op-b-b.cc Fri Jan 03 17:33:46 2014 -0500 +++ b/libinterp/operators/op-b-b.cc Fri Jan 03 20:55:33 2014 -0500 @@ -33,6 +33,7 @@ #include "ov-float.h" #include "ov-re-mat.h" #include "ov-typeinfo.h" +#include "ov-null-mat.h" #include "ops.h" #include "xdiv.h" #include "xpow.h" @@ -92,4 +93,8 @@ INSTALL_CATOP (octave_float_scalar, octave_bool, f_b); INSTALL_ASSIGNCONV (octave_bool, octave_bool, octave_bool_matrix); + + INSTALL_ASSIGNCONV (octave_bool, octave_null_matrix, octave_bool_matrix); + INSTALL_ASSIGNCONV (octave_bool, octave_null_str, octave_bool_matrix); + INSTALL_ASSIGNCONV (octave_bool, octave_null_sq_str, octave_bool_matrix); } diff -r 775e7874b38d -r cda4bd2fd0c0 libinterp/operators/op-int.h --- a/libinterp/operators/op-int.h Fri Jan 03 17:33:46 2014 -0500 +++ b/libinterp/operators/op-int.h Fri Jan 03 20:55:33 2014 -0500 @@ -1160,7 +1160,10 @@ #define OCTAVE_INSTALL_INT_NULL_ASSIGN_OPS(TYPE) \ INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_matrix, TYPE ## null_assign) \ INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_str, TYPE ## null_assign) \ - INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_sq_str, TYPE ## null_assign) + INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_sq_str, TYPE ## null_assign) \ + INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_null_matrix, octave_ ## TYPE ## _matrix) \ + INSTALL_ASSIGNCONV (octave_## TYPE ## _scalar, octave_null_str, octave_ ## TYPE ## _matrix) \ + INSTALL_ASSIGNCONV (octave_## TYPE ## _scalar, octave_null_sq_str, octave_ ## TYPE ## _matrix) #define OCTAVE_INSTALL_INT_OPS(TYPE) \ OCTAVE_INSTALL_SS_INT_OPS (TYPE) \ diff -r 775e7874b38d -r cda4bd2fd0c0 test/null-assign.tst --- a/test/null-assign.tst Fri Jan 03 17:33:46 2014 -0500 +++ b/test/null-assign.tst Fri Jan 03 20:55:33 2014 -0500 @@ -61,3 +61,49 @@ %!test %! a = ones (3); b = []; fail ("subsasgn (a, substruct ('()', {':',1:2}), b)", ".") +%!test +%! classes = {@int8, @int16, @int32, @int64, ... +%! @uint8, @uint16, @uint32, @uint64, ... +%! @single, @double, @logical}; +%! for i = 1:numel (classes) +%! cls = classes{i}; +%! x = cls ([1, 2, 3]); +%! cls_nm = class (x); +%! x(2) = []; +%! assert (x, cls ([1, 3])); +%! assert (class (x), cls_nm); +%! x(2) = []; +%! assert (x, cls (1)); +%! assert (class (x), cls_nm); +%! x(1) = []; +%! assert (x, cls (zeros (1, 0))); +%! assert (class (x), cls_nm); +%! endfor +%! for i = 1:numel (classes) +%! cls = classes{i}; +%! x = cls ([1, 2, 3]); +%! cls_nm = class (x); +%! x(2) = ''; +%! assert (x, cls ([1, 3])); +%! assert (class (x), cls_nm); +%! x(2) = ''; +%! assert (x, cls (1)); +%! assert (class (x), cls_nm); +%! x(1) = ''; +%! assert (x, cls (zeros (1, 0))); +%! assert (class (x), cls_nm); +%! endfor +%! for i = 1:numel (classes) +%! cls = classes{i}; +%! x = cls ([1, 2, 3]); +%! cls_nm = class (x); +%! x(2) = ""; +%! assert (x, cls ([1, 3])); +%! assert (class (x), cls_nm); +%! x(2) = ""; +%! assert (x, cls (1)); +%! assert (class (x), cls_nm); +%! x(1) = ""; +%! assert (x, cls (zeros (1, 0))); +%! assert (class (x), cls_nm); +%! endfor