Suppress bogus warning from gcc 12

It says:

/home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h: In function ‘auto QtPrivate::sequential_erase_with_copy(Container&, const T&) [with Container = QList<void (*)()>; T = void (*)()]’:
/home/qt/qt6dev-src/qtbase/src/corelib/tools/qcontainertools_impl.h:383:14: error: ‘D.282000’ is used uninitialized [-Werror=uninitialized]
  383 |     const T &tCopy = CopyProxy(t);
      |              ^~~~~
cc1plus: all warnings being treated as errors

We can avoid storing the value into a const ref to silence this. Storing
a non-const pointer into a const reference is quite confusing anyway.

Fixes: QTBUG-123486
Pick-to: 6.5 6.6 6.7
Change-Id: I77fcd871724ce7f81b9567603dc5b4cb31f121c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Ulf Hermann 2024-03-19 09:25:42 +01:00 committed by Thiago Macieira
parent 3dba889fef
commit 4662e80755
1 changed files with 1 additions and 2 deletions

View File

@ -380,8 +380,7 @@ template <typename Container, typename T>
auto sequential_erase_with_copy(Container &c, const T &t)
{
using CopyProxy = std::conditional_t<std::is_copy_constructible_v<T>, T, const T &>;
const T &tCopy = CopyProxy(t);
return sequential_erase(c, tCopy);
return sequential_erase(c, CopyProxy(t));
}
template <typename Container, typename T>