From 6069933b57a8c0175596f66fd5e28381b47d1bc5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 Feb 2025 15:16:38 -0800 Subject: [PATCH] Q_ASSERT_X: fix build where (where) or (what) were not castable to bool Amends commit 868645fd3be039e37c96315059ab0b851d022bf4 Code like (qtmultmedia): Q_ASSERT_X(QFile::exists(shaderFile), Q_FUNC_INFO, QStringLiteral("Shader file %1 does not exist").arg(shaderFile).toLatin1()); Change-Id: Iab02812335384115a689fffd871cd478c7c20046 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Marc Mutz --- src/corelib/global/qassert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qassert.h b/src/corelib/global/qassert.h index bfdd69815a3..ec3449814ff 100644 --- a/src/corelib/global/qassert.h +++ b/src/corelib/global/qassert.h @@ -38,10 +38,11 @@ Q_NORETURN Q_DECL_COLD_FUNCTION Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept; +inline bool qt_no_assert_x(bool, const char *, const char *) noexcept { return false; } #if !defined(Q_ASSERT_X) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) -# define Q_ASSERT_X(cond, where, what) static_cast(false && (cond) && (where) && (what)) +# define Q_ASSERT_X(cond, where, what) static_cast(false && qt_no_assert_x(bool(cond), where, what)) # else # define Q_ASSERT_X(cond, where, what) ((cond) ? static_cast(0) : qt_assert_x(where, what, __FILE__, __LINE__)) # endif