Recent warning regression in libstdc++-v3/libsupc++

Mark Mitchell mark@codesourcery.com
Wed Jul 23 17:39:00 GMT 2008


Paolo Carlini wrote:
> ... I see this comment in except.c:do_begin_catch:
> 
>       /* Declare void* __cxa_begin_catch (void *).  */
> 
> Instead, in libstdc++/libsup++/unwind-cxx.h:
> 
>       extern "C" void *__cxa_begin_catch (void *) throw();
> 
> So, who is right? Note, the symbol is exported, I'm not suer which headroom for changes we do have. I would appreciate if Mark could also have a look (as a C++ ABI issue)...

This is not an ABI issue; the presence of absence of an 
exception-specifier does not affect the ABI.  The ABI document:

http://www.codesourcery.com/public/cxx-abi/abi-eh.html

doesn't have a throw-specifier on that routine, so one could argue that 
this means the declaration shouldn't have one.  However, I think that's 
specious; it was intended that these helper functions could even be 
implemented in C, without exceptions.

In general, of course, it's better for optimization purposes if 
functions have "throw()" on them -- provided that all functions they 
call *also* have that marker.  In that case, the compiler can elide the 
exception tables.  The duality here is that if any of the callees do 
*not* have the marker, then the caller must *add* code to catch the 
exceptions thrown by callees and raise std::unexpected.

So, you want to work bottom-up, putting "throw()" on the leaf functions, 
and then on callers that call only "throw()" functions and so forth.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc mailing list