[{"id":27002,"web_url":"https://patchwork.libcamera.org/comment/27002/","msgid":"<168293619284.2176748.3720331261537265081@Monstersaurus>","date":"2023-05-01T10:16:32","subject":"Re: [libcamera-devel] [PATCH] meson: Ignore -Wredundant-move with\n\tgcc-13 and newer","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart via libcamera-devel (2023-05-01 03:57:11)\n> Starting from 13.1, gcc implements the C++23 version of automatic move\n> from local variables in return statements (see\n> https://en.cppreference.com/w/cpp/language/return). As a result, some\n> previously required explicit `std::move()` in return statements generate\n> warnings. This is the case when a function returns an object whose type\n> is a class derived from the class type the function returns:\n> \n> struct U { };\n> struct T : U { };\n> \n> U f()\n> {\n>         T t;\n>         return t;\n> }\n> \n> Up to C++20, the automatic move from local variables selects the move\n> constructor of class U, which is not the move constructor of the\n> expression. Overload resolution is then performed a second time, with t\n> considered as an lvalue. An explicit `std::move(t)` is needed in the\n> return statement to select the U move constructor.\n> \n> Starting from C++23, `t` is treated as an xvalue, and the U move\n> constructor is selected without the need for an explicit `std::move(t)`.\n> An explicit `std:move()` then generates a redundant-move warning, as in\n> the valueOrTuple() function in src/py/libcamera/py_helpers.cpp.\n> \n> Omitting the `std::move()` silences the warning, but selects the copy\n> constructor of U with older gcc versions and with clang, which\n> negatively impacts performance.\n> \n> The easiest fix is to disable the warning. With -Wpessimizing-move\n> enabled, the compiler will still warn of pessimizing moves, only the\n> redundant but not pessimizing moves will be ignored.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nLooks good to me. I'll collect this for v0.0.5 and test with the other\nGCC-13 fix.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  meson.build | 15 +++++++++++++++\n>  1 file changed, 15 insertions(+)\n> \n> diff --git a/meson.build b/meson.build\n> index 8628e6acebee..6e363a906c69 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -136,6 +136,21 @@ if cc.get_id() == 'gcc'\n>          ]\n>      endif\n>  \n> +    # gcc 13 implements the C++23 version of automatic move from local\n> +    # variables in return statements (see\n> +    # https://en.cppreference.com/w/cpp/language/return). As a result, some\n> +    # previously required explicit std::move() in return statements generate\n> +    # warnings. Those moves can't be removed as older compiler versions could\n> +    # use copy constructors instead of move constructors. The easiest fix is to\n> +    # disable the warning. With -Wpessimizing-move enabled, the compiler will\n> +    # still warn of pessimizing moves, only the redundant but not pessimizing\n> +    # moves will be ignored.\n> +    if cc.version().version_compare('>=13')\n> +        cpp_arguments += [\n> +            '-Wno-redundant-move',\n> +        ]\n> +    endif\n> +\n>      # gcc 7.1 introduced processor-specific ABI breakages related to parameter\n>      # passing on ARM platforms. This generates a large number of messages\n>      # during compilation. Silence them.\n> \n> base-commit: 701b201cf387055e5c0a1c9549e2dbbf4988f092\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B716AC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 May 2023 10:16:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 15D55627DF;\n\tMon,  1 May 2023 12:16:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 578DD61EB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 May 2023 12:16:36 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D8F076B8;\n\tMon,  1 May 2023 12:16:34 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682936198;\n\tbh=vOZvGI58G6c8O4ZagY8H2vcvV8oTHeiSZwTt6oWQcls=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=LYASQmn9+4TZP1Ie4ToCuAYeRCebtgUmwm0URoftlvHWhgwaY9ZH+HoVQ6WToKtqM\n\teWlg4EIqPcG6wL5TUj/vXk7sgpXOu/061bBUWK13p7bpJirmbpRtkbuuBy/n9NyGYb\n\tDZC1UYYyyVhVdLdGqSI2P2VQctaWJ84INWPl5+SgqK7ehsBb0LMpczD7DlbbzIR+lp\n\twYcaSJHhz90mRGbKR92bxzBxCPRmwuD3OgM2DkY4WLmEP6bbMdjS0745yLsKkS2+s9\n\to9Sxp/PmTgd1FeDmIYw2rwaJkqVQxPYdApITjQ5/GlwmzHEL8Xr77C6ooOe1+9fCPU\n\trOZKj0bQOnfrA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1682936195;\n\tbh=vOZvGI58G6c8O4ZagY8H2vcvV8oTHeiSZwTt6oWQcls=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=MJ2nUihwECnr35BjNzTeWOC2la3A5MeJ1Q1uDdFhhlhGpe6OZi6F+PtW0nOqzzN5e\n\ttBkPYY1WD+JQzwp/lpvExS9q3+TdJeUYfiKbnxHymcy8MTkU+PY/b939JzxXPe4zDF\n\tZlciiiwot96FiSATSQ0p078So0A172Kx/Pjyzo7Q="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MJ2nUihw\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20230501025711.25157-1-laurent.pinchart@ideasonboard.com>","References":"<20230501025711.25157-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 01 May 2023 11:16:32 +0100","Message-ID":"<168293619284.2176748.3720331261537265081@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] meson: Ignore -Wredundant-move with\n\tgcc-13 and newer","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]