On Friday 24 July 2015 10:36:52 David Krauss wrote:
> The noexcept operator is associated with duplication in more situations. A
> very common idiom is duplication of a function’s body into its exception
> specification using noexcept.
>
> void foo() noexcept( dosomething() )
> { return dosomething(); }
>
> The solution is to introduce noexcept(auto):
>
> void foo() noexcept(auto)
> { return dosomething(); }
We discussed this before, but refresh my mind please: did we agree that
noexcept(auto) should be the default for inline functions?
If the entire body of a function is noexcept, it can't throw. If the function
is inline, then changing it so it later throws but not recompiling everything
is an ODR violation. The standard wouldn't care.
For ABI binary compatibility, the only case that would be problematic is when:
a) the function was inline and thus implicitly noexcept
b) the function was called but not inlined
c) the out-of-line copy is subject to merging across multiple libraries
d) the function was de-inlined and made to throw
e) the dynamic linker chose to call the copy that throws
I find that to be very unlikely to happen, for the following reasons:
1) inline functions get often inlined
2) a good portion of C++ libraries don't try to keep binary compatibility
(boost doesn't even try, for example)
3) of those that do, deinlining is a very uncommon thing to do
4) of those that do keep binary compatibility, a good chunk follow Qt's
paradigm and don't use exceptions
5) on modern operating systems with modern C++ shared libraries that try to
keep binary compatibility, out-of-line copy of inline functions are not
merged across shared library boundaries (-fvisibility-inlines-hidden; for
MSVC, this applies too, except for debug-mode calls to inline member
functions in classes that are __declspec(dllexport)).