meson: Ignore Wredundant-move with GCC 11 and above
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 <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
21
meson.build
21
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',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user