From patchwork Mon May 1 02:57:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 18575 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C99FDC0DA4 for ; Mon, 1 May 2023 02:57:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22320627DF; Mon, 1 May 2023 04:57:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682909826; bh=0M8Ga/RpJJOEGe4DKwsDu5EjbHBzbcHUK4N1F0uZoWo=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=i8hsAJ3yR3G4lTQhB+GKqUeymcASb6tFr2Xivh1jbfO6aLFqJVU8CYYNLHrDhKZsI pbdo5ZSqWDf9Cirjrdk7nuQq15z75agfEmAtZmNZjd9/iARS+uIf4NPjSV9TeC9FuE lQAM7v+n9gfeCdmMzWVwyF1jfUOrLXJKUdmy0QoyiK6VH/TtbL8avADbGiwwDFoQjh GFJWEVzZHTQypcooUlTqbyrOv1snqAZGdtd+jSLePh9ON68YN9vKaZckhW1i3VfZHG 1MzWs6W3tBr/nKH/ZZ0y+SVj8PvWG2O64mvBEk4jQIr9BDwZRioQivVzLYnOnTihWD KYKjoWhUZ+a1A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C90F6627D1 for ; Mon, 1 May 2023 04:57:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ltmMoOge"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 24F90A06; Mon, 1 May 2023 04:56:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1682909821; bh=0M8Ga/RpJJOEGe4DKwsDu5EjbHBzbcHUK4N1F0uZoWo=; h=From:To:Cc:Subject:Date:From; b=ltmMoOgeN4ubeAYuWM30Rk2kAjFqWLZlZLJ07CFAOZBLFpot5LP13MQhI895M2abK 7ycLXWtOoYLojXlRc1ZgJOXKw3vudZEKjOpGhZzl+DT3QeiJFUlPXgbHInxQDVnETC M26gng9FXY6N5tCFEAO9IFgZ2G7/3Y8V3rFCdkOQ= To: libcamera-devel@lists.libcamera.org Date: Mon, 1 May 2023 05:57:11 +0300 Message-Id: <20230501025711.25157-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] meson: Ignore -Wredundant-move with gcc-13 and newer X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Starting from 13.1, gcc 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. This is the case when a function returns an object whose type is a class derived from the class type the function returns: struct U { }; struct T : U { }; U f() { T t; return t; } Up to C++20, the automatic move from local variables selects the move constructor of class U, which is not the move constructor of the expression. Overload resolution is then performed a second time, with t considered as an lvalue. An explicit `std::move(t)` is needed in the return statement to select the U move constructor. Starting from C++23, `t` is treated as an xvalue, and the U move constructor is selected without the need for an explicit `std::move(t)`. An explicit `std:move()` then generates a redundant-move warning, as in the valueOrTuple() function in src/py/libcamera/py_helpers.cpp. Omitting the `std::move()` silences the warning, but selects the copy constructor of U with older gcc versions and with clang, which negatively impacts performance. 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. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- meson.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+) base-commit: 701b201cf387055e5c0a1c9549e2dbbf4988f092 diff --git a/meson.build b/meson.build index 8628e6acebee..6e363a906c69 100644 --- a/meson.build +++ b/meson.build @@ -136,6 +136,21 @@ if cc.get_id() == 'gcc' ] 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') + cpp_arguments += [ + '-Wno-redundant-move', + ] + endif + # gcc 7.1 introduced processor-specific ABI breakages related to parameter # passing on ARM platforms. This generates a large number of messages # during compilation. Silence them.