# HG changeset patch # User John W. Eaton # Date 1711388987 14400 # Node ID 93b856b2d87e70b09fe79e36452a013abb0794a5 # Parent 40fde86be9b00fa113967c167627d9158b27bc73 don't allow error_if and error_unless macros to be defined to be empty * error.h (error_if, error_unless): Don't allow these macros to be defined away by compiling with NDEBUG defined. Update comments to discourage using error_if, error_impossible, and error_unless. diff -r 40fde86be9b0 -r 93b856b2d87e libinterp/corefcn/error.h --- a/libinterp/corefcn/error.h Mon Mar 25 00:42:04 2024 -0400 +++ b/libinterp/corefcn/error.h Mon Mar 25 13:49:47 2024 -0400 @@ -493,20 +493,23 @@ extern OCTINTERP_API void parse_error_with_id (const char *id, const char *fmt, ...); +// Use of the following macros (error_impossible, error_if, and +// error_unless) is discouraged. All of these will only display a +// generic error of the form +// +// impossible state reached in file 'FILE' at line 'N' +// +// If the state really is "impossible" to reach, then it is better to +// use one of the corresponding panic* functions instead (see panic.h). +// +// See also the discussion here: https://octave.discourse.group/t/assert-panic-error-and-ndebug/5409 + #define error_impossible() \ ::error ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__) -#if defined (NDEBUG) -# define error_if(cond) -#else -# define error_if(cond) do { if (cond) error_impossible (); } while (0) -#endif +#define error_if(cond) do { if (cond) error_impossible (); } while (0) -#if defined (NDEBUG) -# define error_unless(cond) -#else -# define error_unless(cond) error_if (! (cond)) -#endif +#define error_unless(cond) error_if (! (cond)) OCTAVE_BEGIN_NAMESPACE(octave)