Commit 1adca807 defined Q_DECL_NOEXCEPT to be the same as throw() for the
Microsoft compiler. However, the two are not equivalent:
- C++11 noexcept is defined to call std::terminate() if a noexcept
function nevertheless encounters an exception.
- MSVC throw() has essentially undefined behaviour in this situation:
http://msdn.microsoft.com/en-us/library/wfa0edys%28v=vs.100%29
"Due to code optimizations that might be performed by the C++
compiler [...] if a function does throw an exception, the program
may not execute correctly."
So define two macros:
1. Q_DECL_NOEXCEPT/Q_DECL_NOEXCEPT_EXPR always have C++11 behaviour.
This is expected to be the more efficient implementation if the
function can actually throw.
2. Q_DECL_NOTHROW means that the function gives the nothrow
guarantee. It is stronger than noexcept, but not all functions
that can be marked Q_DECL_NOEXCEPT can be marked Q_DECL_NOTHROW.
In general Q_DECL_NOTHROW functions need to use a try/catch block
in order to prevent exceptions from leaving the functions, unless
you can proove that none of the operations can throw.
For the caller, both macros are equivalent: it can be relied on that
no exception leaves the function.
Change-Id: I32f822a82e06a31cb71d38db438387aee5ec3334
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>