From 17681b75f7bad1ab80f2bd091691e1d15f7438ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 21 Mar 2025 11:38:41 +0100 Subject: [PATCH] meson: Ignore `Wredundant-move` with GCC 11 and above MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In C++20 mode, object slicing in a return statement triggers automatic move since GCC 11, and using `std::move()` emits `-Wredundant-move` in those same GCC versions. So disable the warning in those as well. This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which returns a `py::tuple` as `py::object`. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- meson.build | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 82867f82..fa38fa2c 100644 --- a/meson.build +++ b/meson.build @@ -159,16 +159,17 @@ if cc.get_id() == 'gcc' error('gcc version is too old, libcamera requires 9.0 or newer') endif - # gcc 13 implements the C++23 version of automatic move from local - # variables in return statements (see - # https://en.cppreference.com/w/cpp/language/return). As a result, some - # previously required explicit std::move() in return statements generate - # warnings. Those moves can't be removed as older compiler versions could - # use copy constructors instead of move constructors. The easiest fix is to - # disable the warning. With -Wpessimizing-move enabled, the compiler will - # still warn of pessimizing moves, only the redundant but not pessimizing - # moves will be ignored. - if cc.version().version_compare('>=13') + # In C++20 mode, prior to gcc 11, object slicing in a return statement didn't + # perform automatic move. It required explicit std::move() usage, which now + # generate warnings. Those moves can't be removed as older compiler versions + # could use copy constructors instead of move constructors. The easiest fix + # is to disable the warning. With -Wpessimizing-move enabled, the compiler + # will still warn of pessimizing moves, only the redundant but not + # pessimizing moves will be ignored. + # + # \todo When dropping support for compilers older than gcc 11, drop the + # argument and remove the unneeded std::move() calls. + if cc.version().version_compare('>=11') cpp_arguments += [ '-Wno-redundant-move', ]