[Xapian-tickets] [Xapian] #454: Mark up methods as "nothrow"

Xapian nobody at xapian.org
Tue Mar 2 03:31:36 GMT 2010


#454: Mark up methods as "nothrow"
--------------------------+-------------------------------------------------
 Reporter:  olly          |       Owner:  olly     
     Type:  enhancement   |      Status:  new      
 Priority:  normal        |   Milestone:  1.2.x    
Component:  Build system  |     Version:  SVN trunk
 Severity:  normal        |    Keywords:           
Blockedby:                |    Platform:  All      
 Blocking:                |  
--------------------------+-------------------------------------------------
 Some compilers support extensions to allow functions and methods to be
 marked as not throwing exceptions.  The compiler can potentially use this
 knowledge to optimise better.

 This applies to both external and internal APIs.  Marking up external APIs
 in this way is probably ABI compatible (provided of course that the
 function/method has never thrown exceptions in any previous ABI-compatible
 version of Xapian).  So marking for 1.2.x.

 Also we can probably use the same machinery to tell SWIG that exception
 handling isn't required for these methods, though I've not yet looked into
 that.

 GCC 3.3 and later support:

 {{{
 #!cpp
 int func() __attribute__((nothrow));
 }}}

 http://gcc.gnu.org/onlinedocs/gcc-4.3.2//gcc/Function-Attributes.html

 MSVC apparently has:

 {{{
 #!cpp
 int __declspec(nothrow) func();
 }}}

 These are a better approach than the standard C++ {{{throw()}}} specifier,
 because the compiler is required to add a runtime check that the function
 really doesn't throw an exception (unless the compiler can prove that it
 can't, in which case the nothrow status can be inferred automatically
 anyway).

-- 
Ticket URL: <http://trac.xapian.org/ticket/454>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list