summaryrefslogtreecommitdiff
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-06-17 08:42:03 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-22 04:12:41 +0000
commit453fbbc2e83f0caf75c9680e4a3f5c29d1489b32 (patch)
treefb64a47f88430fdda8175627d28fa678700853c9 /tests/benchmarks
parent2b291f05a307195bd301996cd7ce981e9dc1ff3a (diff)
downloadqtbase-453fbbc2e83f0caf75c9680e4a3f5c29d1489b32.tar.gz
tst_bench_shared_ptr: fix build with BOOST_NO_EXCEPTIONS
If, for whatever reason, BOOST_NO_EXCEPTIONS is defined, the user of the Boost libraries is supposed to provide a definition of boost::throw_exception, which we didn't. We used to run into this only on ubsan builds, but it seems we now have the problem on a regular Ubuntu 22.04 build, too (cf. bugreport). Fix by adding the necessary definitions. Fixes: QTBUG-104083 Change-Id: I9b061a158a5b77e8d286bd7b40312e5bc63ee8de Reviewed-by: MĂ„rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 882fc48b9e0966c8d93ce71e0843a3c50da97be8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp b/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
index 55071120b2..b00bef96d4 100644
--- a/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
+++ b/tests/benchmarks/corelib/tools/qsharedpointer/tst_bench_shared_ptr.cpp
@@ -1,4 +1,5 @@
// Copyright (C) 2021 KlarÀlvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QObject>
@@ -14,6 +15,18 @@
#if __has_include(<boost/shared_ptr.hpp>)
# include <boost/shared_ptr.hpp>
# include <boost/make_shared.hpp>
+
+# ifdef BOOST_NO_EXCEPTIONS
+// https://stackoverflow.com/a/9530546/134841
+// https://www.boost.org/doc/libs/1_79_0/libs/throw_exception/doc/html/throw_exception.html#throw_exception
+BOOST_NORETURN void boost::throw_exception(const std::exception &) { std::terminate(); }
+# if BOOST_VERSION >= 107300
+// https://www.boost.org/doc/libs/1_79_0/libs/throw_exception/doc/html/throw_exception.html#changes_in_1_73_0
+BOOST_NORETURN void boost::throw_exception(const std::exception &, const boost::source_location &)
+{ std::terminate(); }
+# endif // Boost v1.73
+# endif // BOOST_NO_EXCEPTIONS
+
# define ONLY_IF_BOOST(x) x
#else
# define ONLY_IF_BOOST(x) QSKIP("This benchmark requires Boost.SharedPtr.")