This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Exceptions, C, and Gcc


Kevin Atkinson <kevin at atkinson dot dhs dot org> writes:

> 1) Is it or will it ever be safe to throw exceptions when a C function 
> calls a C++ via a callback.  Especially when use of a longjmp would be 
> safe.  (Ie the program will remain in a consistent state even if the 
> handler functions does not return).  Since C does not have destructors I 
> can't think of anything that needs to be done other than popping the stack.

Yes, but you must compile all of the C code with -fexceptions; this is
off by default to save space.

> 2) Are exceptions fast and stable enough to use in Gcc 3.1+.  I once used 
> exceptions with Gcc (egcs 1.1 and Gcc 2.95) and stopped due to buggy 
> implementations.  I had reports that in some cases exceptions were not 
> being caught at all.  In particular are exceptions _faster_ than 
> traditional error handling of checking return type for every function 
> called that can have an error.

We are confident that exceptions are reliable in 3.2+.  We do not have
hard numbers comparing performance; we would be interested to see them
if you come up with any.  They should, at least, not be painfully slow
as they were in 2.x.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]