Opened 15 years ago
Closed 5 years ago
#454 closed enhancement (fixed)
Move to noexcept
Reported by: | Olly Betts | Owned by: | Olly Betts |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.0 |
Component: | Build system | Version: | git master |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | All |
Description (last modified by )
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:
int func() __attribute__((nothrow));
http://gcc.gnu.org/onlinedocs/gcc-4.3.2//gcc/Function-Attributes.html
MSVC apparently has:
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!)
Change History (8)
comment:1 by , 14 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
Milestone: | 1.2.x → 1.3.x |
---|
comment:3 by , 13 years ago
C++11 adds noexcept(true)
as a standard way to support this:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
comment:4 by , 12 years ago
comment:5 by , 9 years ago
Milestone: | 1.3.x → 1.4.x |
---|
I marked more cases in the public API in a few commits which are in 1.3.3, plus some methods in Query::Internal
. I think everything in the public API which could be marked now is.
There are probably more internal functions and methods which could be marked, but there's no reason to block 1.4.0 for that.
comment:6 by , 5 years ago
Milestone: | 1.4.x → 1.5.0 |
---|---|
Status: | new → assigned |
Summary: | Mark up methods as "nothrow" → Move to noexcept(true) |
Version: | SVN trunk → git master |
We now require a C++11 compiler for the API headers too so we should probably drop XAPIAN_NOTHROW
and XAPIAN_NOEXCEPT
and just use noexcept(true)
instead.
The awkward part is we currently rely on crudely parsing XAPIAN_NOTHROW
to avoid exception wrapping methods which can't throw, but perhaps we can get SWIG to do that for us automatically.
comment:7 by , 5 years ago
Summary: | Move to noexcept(true) → Move to noexcept |
---|
Actually, just noexcept
works and is shorter and clearer than noexcept(true)
.
comment:8 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Moved to noexcept
in 3cc4ef58834b0defc2d4ffb71fa4f10d375afc11 for git master. Not suitable for 1.4.x as we don't assume a C++11 compiler for code using Xapian there.
There might still be more places we could use noexcept
internally, but I don't think we need to keep a ticket open for that.
Clarify ambiguity in description.