summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-01-17 19:07:48 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-01-19 22:35:17 +0100
commit790b600840920f8ac4f56af1e1232cd97ad510bd (patch)
treed259394df543fb8c83a1b374e6c9a3fd6c3f5fdf /src/corelib/global/qglobal.cpp
parent813a928c7c3cf98670b6043149880ed5c955efb9 (diff)
Mark qBadAlloc as [[noreturn]]
So that static analyzers don't get confused by its semantics. In builds with exceptions disabled, it's not actually called by client code (e.g. Q_CHECK_PTR will just terminate in that case), but we still need to make it not return -- add another path that callss std::terminate(), otherwise we'd have a noreturn function returning. Change-Id: Ia8c4ce3e9d971f1757e9c273051cb3dedf23c61f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r--src/corelib/global/qglobal.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 65c72d9abe..139c8f3a30 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -3098,7 +3098,11 @@ void qt_check_pointer(const char *n, int l) noexcept
*/
void qBadAlloc()
{
+#ifndef QT_NO_EXCEPTIONS
QT_THROW(std::bad_alloc());
+#else
+ std::terminate();
+#endif
}
#ifndef QT_NO_EXCEPTIONS