path: root/tests/benchmarks
diff options
authorMarc Mutz <>2012-08-07 01:54:13 +0200
committerQt by Nokia <>2012-08-07 21:11:55 +0200
commitf829ab5573f7146785c79d83182757043b0e6ce9 (patch)
treebf164c6f38044de5df0e5dde19ab8cae84bb9e7b /tests/benchmarks
parent46212d657e2e989dddd361a732e65b05748e8e91 (diff)
Q_DECL_NOTHROW: stronger and more widely available version of Q_DECL_NOEXCEPT
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: "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 <> Reviewed-by: Marius Storm-Olsen <>
Diffstat (limited to 'tests/benchmarks')
0 files changed, 0 insertions, 0 deletions