Mercurial > octave-dspies
view liboctave/util/lo-array-gripes.h @ 19009:8d47ce2053f2 draft
Added safety checks to Array::xelem
There's no reason to have a method which never checks invariants, ever. Added
debugging checks to Array::xelem to help catch and debug out-of-bounds errors
and reference overlap
* configure.ac: Added configuration option for uniqueness-checking with xelem
* jit-typeinfo.cc (octave_jit_paren_scalar): Call const Array::xelem rather
than Array::xelem
* Array-util.h, Array-util.cc (check_out_of_range): Extract common pattern to
method
(check_index): Methods to check index is in-bounds
(compute_index): Added bool parameter check. does not check bounds when check
is false and BOUNDS_CHECKING is off
* Array.h, Array.cc (xelem): Use methods from Array-util.h to compute indices
(is_unique): Check if this is the only reference to data
* CmplxQR.cc, dbleQR.cc, fCmplxQR.cc, floatQR.cc
(form): Move second assignment to after the call to xelem
* lo-array-gripes.h, lo-array-gripes.cc (gripe_modifying_nonunique): Added
error message for when non-const xelem is called on non-unique array
author | David Spies <dnspies@gmail.com> |
---|---|
date | Mon, 14 Jul 2014 13:07:59 -0600 |
parents | ebb3ef964372 |
children |
line wrap: on
line source
/* Copyright (C) 2000-2013 John W. Eaton This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, see <http://www.gnu.org/licenses/>. */ #if !defined (octave_lo_array_gripes_h) #define octave_lo_array_gripes_h 1 #include "dim-vector.h" extern OCTAVE_API const char *error_id_nonconformant_args; extern OCTAVE_API const char *error_id_index_out_of_bounds; extern OCTAVE_API const char *error_id_invalid_index; extern void OCTAVE_API gripe_nan_to_logical_conversion (void); extern void OCTAVE_API gripe_nan_to_character_conversion (void); extern void OCTAVE_API gripe_nonconformant (const char *op, octave_idx_type op1_len, octave_idx_type op2_len); extern void OCTAVE_API gripe_nonconformant (const char *op, octave_idx_type op1_nr, octave_idx_type op1_nc, octave_idx_type op2_nr, octave_idx_type op2_nc); extern void OCTAVE_API gripe_nonconformant (const char *op, const dim_vector& op1_dims, const dim_vector& op2_dims); extern void OCTAVE_API gripe_index_out_of_range (int nd, int dim, octave_idx_type iext, octave_idx_type ext); extern void OCTAVE_API gripe_del_index_out_of_range (bool is1d, octave_idx_type iext, octave_idx_type ext); extern void OCTAVE_API gripe_invalid_index (void); extern void OCTAVE_API gripe_invalid_resize (void); extern void OCTAVE_API gripe_invalid_assignment_size (void); extern void OCTAVE_API gripe_assignment_dimension_mismatch (void); extern void OCTAVE_API gripe_modifying_nonunique (void); #endif