[CLN-list] Overriding read_number_bad_syntax on OS X

Bruno Haible bruno at clisp.org
Mon May 21 01:12:42 CEST 2007


Hello Richy,

Richard B. Kreckel wrote:
> I'm proceeding with the convertion to throwing exceptions. However, I'm 
> feeling unconfident with some of them. Many of the cl_abort calls should 
> really be assertions IMO. Is there a point throwing at a code section 
> that cannot possibly be reached, except when someone seriously screws up 
> CLN?

You're right, "not reached"/"internal error"/"assertion" are a different
type of situation: here the culprit is inside CLN.

How to signal this situation?
  - through abort()?
  - through throw internal_error(...)?
I don't like abort() in the context of CLN, since it would create huge
coredumps (1 GB is not rare), and eating that much of a user's disk is
simply not nice.
Therefore I'm in favour of an exception class that can be used for
"not reached"/"internal error"/"assertion".

> One of the most striking examples is the definition of 
> CL_DEFINE_CONVERTER in include/cln/object.h. The conditional there could 
> even be written as a compile-time assertion!

Yes, please make it a compile-time assertion!
   if (sizeof(*this) != sizeof(target_class)) cl_abort();
becomes
   typedef int verify_size_in_CL_DEFINE_CONVERTER[2*(sizeof(*this)==sizeof(target_class))-1];

Also, there is the documented use of cl_abort in the manual, section
"Debugging support". How can we keep this functionality, i.e. have a way to
put a breakpoint in a single place, so that the program execution stops
there after any CLN exception is constructed but before it is thrown?
Does "break __cxa_throw" work? If not, it can be done by defining an
empty function cl_exception_breakpoint(){} and calling this function at the
end of the constructor of every concrete CLN exception class.

Bruno



More information about the CLN-list mailing list