From e160cded0ac6e08aaf3fdce55b567ed26bc40f34 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 30 Jun 2021 13:37:24 +0200 Subject: QGlobalStatic: fix warning when using cv-qualified types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Says GCC: tst_qglobalstatic.cpp: In function ‘{anonymous}::Q_QGS_constInt::Type* {anonymous}::Q_QGS_constInt::innerFunction()’: tst_qglobalstatic.cpp:71:51: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers] 71 | Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42)) | ^ qglobalstatic.h:80:40: note: in definition of macro ‘Q_GLOBAL_STATIC_INTERNAL’ 80 | noexcept(noexcept(Type ARGS)) | ^~~~ tst_qglobalstatic.cpp:71:1: note: in expansion of macro ‘Q_GLOBAL_STATIC_WITH_ARGS’ 71 | Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42)) | ^~~~~~~~~~~~~~~~~~~~~~~~~ Fix by a strategic std::remove_cv_t. Pick-to: 6.2 5.15 Change-Id: If2d81b7965cefdcf3ec115bafb78aabc78d4256c Reviewed-by: Thiago Macieira --- src/corelib/global/qglobalstatic.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 034ef274fa..4aa496e7f6 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -44,6 +44,8 @@ #include +#include + QT_BEGIN_NAMESPACE namespace QtGlobalStatic { @@ -77,7 +79,7 @@ enum GuardValues { static struct Holder : public HolderBase { \ Type value; \ Holder() \ - noexcept(noexcept(Type ARGS)) \ + noexcept(noexcept(typename std::remove_cv::type ARGS)) \ : value ARGS \ { guard.storeRelaxed(QtGlobalStatic::Initialized); } \ } holder; \ -- cgit v1.2.3