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

Xapian nobody at xapian.org
Thu May 12 03:23:51 BST 2011


#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:                |  
--------------------------+-------------------------------------------------

Old description:

> 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).

New description:

 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 that requires the compiler 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!)

--

Comment(by olly):

 Clarify ambiguity in description.

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



More information about the Xapian-tickets mailing list