diff libinterp/octave-value/ov-class.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 83f9f8bda883
children 32d2b6604a9f
line wrap: on
line diff
--- a/libinterp/octave-value/ov-class.cc	Mon Feb 07 10:46:17 2022 +0900
+++ b/libinterp/octave-value/ov-class.cc	Mon Feb 07 21:47:53 2022 -0800
@@ -281,7 +281,7 @@
 Cell
 octave_class::dotref (const octave_value_list& idx)
 {
-  assert (idx.length () == 1);
+  panic_if (idx.length () != 1);
 
   std::string method_class = get_current_method_class ();
 
@@ -654,7 +654,7 @@
 
                 octave_value_list key_idx = *++p;
 
-                assert (key_idx.length () == 1);
+                panic_if (key_idx.length () != 1);
 
                 std::string key = key_idx(0).xstring_value ("invalid index for class assignment");
 
@@ -692,7 +692,7 @@
           {
             octave_value_list key_idx = idx.front ();
 
-            assert (key_idx.length () == 1);
+            panic_if (key_idx.length () != 1);
 
             std::string key = key_idx(0).string_value ();
 
@@ -747,7 +747,7 @@
             auto p = idx.begin ();
             octave_value_list key_idx = *++p;
 
-            assert (key_idx.length () == 1);
+            panic_if (key_idx.length () != 1);
 
             std::string key = key_idx(0).xstring_value ("assignment to class element failed");
 
@@ -785,7 +785,7 @@
       {
         octave_value_list key_idx = idx.front ();
 
-        assert (key_idx.length () == 1);
+        panic_if (key_idx.length () != 1);
 
         std::string key = key_idx(0).string_value ();
 
@@ -1068,7 +1068,7 @@
           // Something has gone terribly wrong if
           // symbol_table::find_method (c_name, c_name) does not return
           // a class constructor for the class c_name...
-          assert (have_ctor);
+          panic_unless (have_ctor);
         }
 
       if (have_ctor)