From 3b0ed624351441a2d7be45cf9582fd36955ae860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 10 Jan 2013 10:05:02 +0100 Subject: Protect Q_UNREACHABLE and Q_ASSUME by Q_ASSERT. Both Q_UNREACHABLE and Q_ASSUME with an invalid condition can produce really weird side effects and crashes. Change-Id: I4d808c705ae98388ef5853e6539b70bd5e5ad34b Reviewed-by: Simon Hausmann Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/global/qglobal.cpp') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 3881b166b1..6818b1d64d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1829,6 +1829,8 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion() that the current code execution cannot be reached. That is, Q_ASSUME(false) is equivalent to Q_UNREACHABLE(). + In debug builds the condition is enforced by an assert to facilitate debugging. + \note Q_LIKELY() tells the compiler that the expression is likely, but not the only possibility. Q_ASSUME tells the compiler that it is the only possibility. @@ -1863,6 +1865,8 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion() By using this macro in impossible conditions, code coverage may be improved as dead code paths may be eliminated. + In debug builds the condition is enforced by an assert to facilitate debugging. + \sa Q_ASSERT(), Q_ASSUME(), qFatal() */ -- cgit v1.2.3