comparison libinterp/parse-tree/pt-tm-const.cc @ 30723:08b08b7f05b2

Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753) Define 4 new inline functions in error.h (panic_if, panic_unless, error_if, error_unless) that call either assert() or Octave's own error() function. Replace calls to assert() in code that maintains state and for which no recovery on detection of a problem is possible with calls to panic_XXX. Replace calls to assert() in interpreter code which could simply return to the Octave prompt when a problem is detected with calls to error_XXX. * error.h (panic_if, panic_unless): New functions which eventually call can call assert(). panic_if (COND) calls assert if COND is true. panic_unless (COND) calls assert if COND is false. * error.h (error_if, error_unless): New functions which eventually call can call Octave's error() function. error_if (COND) calls assert if COND is true. error_unless (COND) calls assert if COND is false. * cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, dot.cc, error.cc, graphics.cc, kron.cc, mex.cc, oct-map.cc, oct-stream.cc, pr-output.cc, schur.cc, stack-frame.cc, typecast.cc, variables.cc, ov-base.cc, ov-class.cc, ov-fcn-handle.cc, ov-struct.cc, ov-usr-fcn.cc, ov.h, ovl.cc, ops.h, profiler.cc, pt-classdef.cc, pt-eval.cc, pt-idx.cc, pt-pr-code.cc, pt-tm-const.cc, token.cc: Replace direct calls to C library assert() with Octave specialty functions.
author Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
date Mon, 07 Feb 2022 21:47:53 -0800
parents 796f54d4ddbf
children e88a07dec498
comparison
equal deleted inserted replaced
30720:25de51cb4123 30723:08b08b7f05b2
606 || equal_types<ELT_T, octave_value>::value) 606 || equal_types<ELT_T, octave_value>::value)
607 && row.all_1x1_p ()) 607 && row.all_1x1_p ())
608 { 608 {
609 // Optimize all scalars case. 609 // Optimize all scalars case.
610 TYPE result (m_dv); 610 TYPE result (m_dv);
611 assert (static_cast<std::size_t> (result.numel ()) == row.length ()); 611 panic_unless (static_cast<std::size_t> (result.numel ())
612 == row.length ());
612 octave_idx_type i = 0; 613 octave_idx_type i = 0;
613 for (const auto& elt : row) 614 for (const auto& elt : row)
614 result(i++) = octave_value_extract<ELT_T> (elt); 615 result(i++) = octave_value_extract<ELT_T> (elt);
615 616
616 return result; 617 return result;