From 3fd7086878ea03861fc82348fc5b4e77f76b2a86 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 21 Apr 2023 15:46:21 +0200 Subject: Silence MSVC warning on constructing QList from initializer_list MSVC complains because we call Data::allocate(args.size()) and, of course, initializer_list::size() returns unsigned std::size_type, while the relevant Data::allocate() overload takes a signed qsizetype. The constructor from iterators potentially has the same problem, if the iterator type's difference_type is unsigned, so make the type-conversion overt there, too. Pick-to: 6.2 6.5 Change-Id: I521eca26a48aed570855b13242bf2df8bfa38f96 Reviewed-by: Thiago Macieira --- src/corelib/tools/qlist.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index cc65039941..d61b90503a 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -274,7 +274,7 @@ public: } inline QList(std::initializer_list args) - : d(Data::allocate(args.size())) + : d(Data::allocate(qsizetype(args.size()))) { if (args.size()) d->copyAppend(args.begin(), args.end()); @@ -282,7 +282,7 @@ public: QList &operator=(std::initializer_list args) { - d = DataPointer(Data::allocate(args.size())); + d = DataPointer(Data::allocate(qsizetype(args.size()))); if (args.size()) d->copyAppend(args.begin(), args.end()); return *this; @@ -295,7 +295,7 @@ public: } else { const auto distance = std::distance(i1, i2); if (distance) { - d = DataPointer(Data::allocate(distance)); + d = DataPointer(Data::allocate(qsizetype(distance))); // appendIteratorRange can deal with contiguous iterators on its own, // this is an optimization for C++17 code. if constexpr (std::is_same_v, iterator> || -- cgit v1.2.3