QRM: silence gcc warning that an array can never be nullptr

If T is a C-array, like it is in some of our tests, then an instance of
that can never be nullptr, which recent gcc versions think warrants a
compile time warning -Waddress.

As a C array is a valid data structure to instantiate a QRangeModel
from, silence that warning by handling the case explicitly.

Change-Id: I63090891988e677cf3ae2d871418b1abd4d1dc71
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
(cherry picked from commit 7ac8815a1943ced73a1c34a05ec7db318f6957d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2025-06-11 11:25:17 +02:00 committed by Qt Cherry-pick Bot
parent 603e0710af
commit b5e05f32e6

View File

@ -101,7 +101,9 @@ namespace QRangeModelDetails
template <typename T>
static constexpr bool isValid(const T &t) noexcept
{
if constexpr (is_validatable<T>())
if constexpr (std::is_array_v<T>)
return true;
else if constexpr (is_validatable<T>())
return bool(t);
else
return true;