--- octave-4.0.0/liboctave/array/Array.cc 2015-05-24 00:21:53.000000000 +1000 +++ octave-4.0.0-play/liboctave/array/Array.cc 2015-07-03 19:39:00.262718702 +1000 @@ -1183,6 +1183,7 @@ gripe_invalid_assignment_size (); } +// Assignment to a 2-dimensional array template void Array::assign (const idx_vector& i, const idx_vector& j, @@ -1281,10 +1282,12 @@ } } } - else - gripe_assignment_dimension_mismatch (); + // any empty RHS can be assigned to an empty LHS + else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0)) + gripe_assignment_dimension_mismatch (); } +// Assignment to a multi-dimensional array template void Array::assign (const Array& ia, @@ -1384,7 +1387,17 @@ } } else - gripe_assignment_dimension_mismatch (); + { // dimension mismatch, unless LHS and RHS both empty + bool lhempty = false, rhempty = false; + for (int i = 0; i < ial; i++) + { + octave_idx_type l = ia(i).length (rdv(i)); + lhempty = lhempty || (l == 0); + rhempty = rhempty || (rhdv(j++) == 0); + } + if (!lhempty || !rhempty) + gripe_assignment_dimension_mismatch (); + } } }