[{"id":37521,"web_url":"https://patchwork.libcamera.org/comment/37521/","msgid":"<20260107202525.GF20168@pendragon.ideasonboard.com>","date":"2026-01-07T20:25:25","subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Wed, Jan 07, 2026 at 08:36:04PM +0100, Barnabás Pőcze wrote:\n> In C++20 mode, object slicing in a return statement triggers automatic move\n> since GCC 11, and using `std::move()` emits `-Wredundant-move` in those\n> same GCC versions. So disable the warning in those as well.\n\nReading https://en.cppreference.com/w/cpp/language/return.html, do I\nunderstand correctly that in C++20 the following clause stops applying,\nand that's what causes the difference in behaviour due to the \"formally\"\npart ?\n\n  or it succeeded, but did not select the move constructor (formally,\n  the first parameter of the selected constructor was not an rvalue\n  reference to the (possibly cv-qualified) type of expression)\n\n> This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which\n> returns a `py::tuple` as `py::object`.\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  meson.build | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/meson.build b/meson.build\n> index 4aa7ecc96..1d8e1d994 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -168,7 +168,7 @@ if cc.get_id() == 'gcc'\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\nExpanding the context:\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\nThis would look odd compared to the version check below. We can't just\ns/13/11/ as that wouldn't be correct, so we probably need to list both\nversions with their corresponding behaviour.\n\n> -    if cc.version().version_compare('>=13')\n> +    if cc.version().version_compare('>=11')\n>          cpp_arguments += [\n>              '-Wno-redundant-move',\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 37121BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Jan 2026 20:25:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E17E161FA0;\n\tWed,  7 Jan 2026 21:25:45 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC57661FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Jan 2026 21:25:43 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BB66F593;\n\tWed,  7 Jan 2026 21:25:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kpiuRBbk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767817521;\n\tbh=UnpwJ9vvPuFHcKBE5UvaTcDWjJc+1zxhc0Bo1bUgI4Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=kpiuRBbklfub/Ry3ooYzUrwxn0n2BPtXrDNIpNqjTIJKVyDdJoW7N9WO2l9KGyTA0\n\tiPTfUAPMjPC7DTV4+n12tuRqjTKVFo0i6cCKbgBi5a7ifENVp9DHpvc/JRx3WbsjQ2\n\t30YWmu30tCn6dJhaoo+7xibPamThZfenYsVtpPZE=","Date":"Wed, 7 Jan 2026 22:25:25 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","Message-ID":"<20260107202525.GF20168@pendragon.ideasonboard.com>","References":"<20260107193607.2168539-1-barnabas.pocze@ideasonboard.com>\n\t<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37527,"web_url":"https://patchwork.libcamera.org/comment/37527/","msgid":"<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>","date":"2026-01-08T09:05:25","subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 07. 21:25 keltezéssel, Laurent Pinchart írta:\n> Hi Barnabás,\n> \n> Thank you for the patch.\n> \n> On Wed, Jan 07, 2026 at 08:36:04PM +0100, Barnabás Pőcze wrote:\n>> In C++20 mode, object slicing in a return statement triggers automatic move\n>> since GCC 11, and using `std::move()` emits `-Wredundant-move` in those\n>> same GCC versions. So disable the warning in those as well.\n> \n> Reading https://en.cppreference.com/w/cpp/language/return.html, do I\n> understand correctly that in C++20 the following clause stops applying,\n> and that's what causes the difference in behaviour due to the \"formally\"\n> part ?\n> \n>    or it succeeded, but did not select the move constructor (formally,\n>    the first parameter of the selected constructor was not an rvalue\n>    reference to the (possibly cv-qualified) type of expression)\n\nI believe the relevant document is https://wg21.link/p1155r3#slicing\n\n\n> \n>> This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which\n>> returns a `py::tuple` as `py::object`.\n>>\n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   meson.build | 2 +-\n>>   1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/meson.build b/meson.build\n>> index 4aa7ecc96..1d8e1d994 100644\n>> --- a/meson.build\n>> +++ b/meson.build\n>> @@ -168,7 +168,7 @@ if cc.get_id() == 'gcc'\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> \n> Expanding the context:\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> \n> This would look odd compared to the version check below. We can't just\n> s/13/11/ as that wouldn't be correct, so we probably need to list both\n> versions with their corresponding behaviour.\n\nThis is the behaviour of when object slicing in the return statement:\n\n      -std=c++17       -std=c++20\n   8:   move             move\n   9:   copy             copy\n  10:   copy             copy\n  11:   copy             move\n  12:   copy             move\n  13:   move             move\n  14:   move             move\n  15:   move             move\n\nSince GCC 8 is not supported. I think it is enough to just state that\nsince GCC 11 automatic move happens when the object is sliced, which\nis I think the problematic case for libcamera.\n\n\n> \n>> -    if cc.version().version_compare('>=13')\n>> +    if cc.version().version_compare('>=11')\n>>           cpp_arguments += [\n>>               '-Wno-redundant-move',\n>>           ]\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 ECEA1BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Jan 2026 09:05:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D5AB61FA0;\n\tThu,  8 Jan 2026 10:05:32 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C51E61A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Jan 2026 10:05:30 +0100 (CET)","from [192.168.33.36] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D47E56D;\n\tThu,  8 Jan 2026 10:05:06 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TpXy9x4U\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767863107;\n\tbh=mmcYP134TkGYsz6kguEkcnw8Kbs36SiaKg2H+9bjb14=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=TpXy9x4UheUyS+R0o5hW/4xcdnYPs6GNF3OwNcH8alWQZa3NYAACRBg1rhWC+x+zc\n\t2OZRHGiud64WBXB5SaTv7jhElG0O1FZmxzpykQy/k4Q7BrcKqEsgquH61Ld2zVgyDT\n\tMlFlqrHSJevMZ4mVSbrkOWjshQfYAtps16h4DwOI=","Message-ID":"<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>","Date":"Thu, 8 Jan 2026 10:05:25 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>","References":"<20260107193607.2168539-1-barnabas.pocze@ideasonboard.com>\n\t<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>\n\t<20260107202525.GF20168@pendragon.ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260107202525.GF20168@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37535,"web_url":"https://patchwork.libcamera.org/comment/37535/","msgid":"<20260109091948.GB20376@pendragon.ideasonboard.com>","date":"2026-01-09T09:19:48","subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jan 08, 2026 at 10:05:25AM +0100, Barnabás Pőcze wrote:\n> 2026. 01. 07. 21:25 keltezéssel, Laurent Pinchart írta:\n> > On Wed, Jan 07, 2026 at 08:36:04PM +0100, Barnabás Pőcze wrote:\n> >> In C++20 mode, object slicing in a return statement triggers automatic move\n> >> since GCC 11, and using `std::move()` emits `-Wredundant-move` in those\n> >> same GCC versions. So disable the warning in those as well.\n> > \n> > Reading https://en.cppreference.com/w/cpp/language/return.html, do I\n> > understand correctly that in C++20 the following clause stops applying,\n> > and that's what causes the difference in behaviour due to the \"formally\"\n> > part ?\n> > \n> >    or it succeeded, but did not select the move constructor (formally,\n> >    the first parameter of the selected constructor was not an rvalue\n> >    reference to the (possibly cv-qualified) type of expression)\n> \n> I believe the relevant document is https://wg21.link/p1155r3#slicing\n\nThanks, that matches my understanding. It must be tough writing a\ncompiler, one needs a special mindset to adhere strictly to the spec\ninstead of interpreting it in an optimized way.\n\n> >> This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which\n> >> returns a `py::tuple` as `py::object`.\n> >>\n> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >> ---\n> >>   meson.build | 2 +-\n> >>   1 file changed, 1 insertion(+), 1 deletion(-)\n> >>\n> >> diff --git a/meson.build b/meson.build\n> >> index 4aa7ecc96..1d8e1d994 100644\n> >> --- a/meson.build\n> >> +++ b/meson.build\n> >> @@ -168,7 +168,7 @@ if cc.get_id() == 'gcc'\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> > \n> > Expanding the context:\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> > \n> > This would look odd compared to the version check below. We can't just\n> > s/13/11/ as that wouldn't be correct, so we probably need to list both\n> > versions with their corresponding behaviour.\n> \n> This is the behaviour of when object slicing in the return statement:\n> \n>       -std=c++17       -std=c++20\n>    8:   move             move\n>    9:   copy             copy\n>   10:   copy             copy\n>   11:   copy             move\n>   12:   copy             move\n>   13:   move             move\n>   14:   move             move\n>   15:   move             move\n> \n> Since GCC 8 is not supported. I think it is enough to just state that\n> since GCC 11 automatic move happens when the object is sliced, which\n> is I think the problematic case for libcamera.\n\nFor the issue you're fixing here, yes, but we also have the current\nissue that is separate and occurs with gcc <13. If we document the first\none only, we'll drop -Wno-redundant-move when dropping support for gcc\nolder than 11 and issues will occur with gcc older than 13. I suppose\nthey will be caught by CI though, so maybe it's OK?\n\n> >> -    if cc.version().version_compare('>=13')\n> >> +    if cc.version().version_compare('>=11')\n> >>           cpp_arguments += [\n> >>               '-Wno-redundant-move',\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 1DED7BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  9 Jan 2026 09:20:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E4F7161FC1;\n\tFri,  9 Jan 2026 10:20:09 +0100 (CET)","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 2A9EA606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  9 Jan 2026 10:20:08 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id C9E833A2;\n\tFri,  9 Jan 2026 10:19:44 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"v/DSBSXf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767950385;\n\tbh=1ReVMVx05NdzE0jbD1z+ZSI7DiZqwyATvzsaTsJv0z8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=v/DSBSXf5V8KOpP4+tk+DVhVp72eNYcJrkxxY7rYpTdqXUYOBcnwKFnEdlwBqtX1b\n\tHQuBS6Vis4TbD8fpqy/cPatahwdgv/PavQVrNHRtbEA0NaZLLudmo/BlpTmxP1cMrq\n\t57tj8dVaWg/GHpj/lu+MywecjNnRXmICqkw+7Rtw=","Date":"Fri, 9 Jan 2026 11:19:48 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","Message-ID":"<20260109091948.GB20376@pendragon.ideasonboard.com>","References":"<20260107193607.2168539-1-barnabas.pocze@ideasonboard.com>\n\t<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>\n\t<20260107202525.GF20168@pendragon.ideasonboard.com>\n\t<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37541,"web_url":"https://patchwork.libcamera.org/comment/37541/","msgid":"<18fe9503-c4e6-45a2-8984-08611ed7527e@ideasonboard.com>","date":"2026-01-09T10:32:16","subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 09. 10:19 keltezéssel, Laurent Pinchart írta:\n> On Thu, Jan 08, 2026 at 10:05:25AM +0100, Barnabás Pőcze wrote:\n>> 2026. 01. 07. 21:25 keltezéssel, Laurent Pinchart írta:\n>>> On Wed, Jan 07, 2026 at 08:36:04PM +0100, Barnabás Pőcze wrote:\n>>>> In C++20 mode, object slicing in a return statement triggers automatic move\n>>>> since GCC 11, and using `std::move()` emits `-Wredundant-move` in those\n>>>> same GCC versions. So disable the warning in those as well.\n>>>\n>>> Reading https://en.cppreference.com/w/cpp/language/return.html, do I\n>>> understand correctly that in C++20 the following clause stops applying,\n>>> and that's what causes the difference in behaviour due to the \"formally\"\n>>> part ?\n>>>\n>>>     or it succeeded, but did not select the move constructor (formally,\n>>>     the first parameter of the selected constructor was not an rvalue\n>>>     reference to the (possibly cv-qualified) type of expression)\n>>\n>> I believe the relevant document is https://wg21.link/p1155r3#slicing\n> \n> Thanks, that matches my understanding. It must be tough writing a\n> compiler, one needs a special mindset to adhere strictly to the spec\n> instead of interpreting it in an optimized way.\n> \n>>>> This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which\n>>>> returns a `py::tuple` as `py::object`.\n>>>>\n>>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>>>> ---\n>>>>    meson.build | 2 +-\n>>>>    1 file changed, 1 insertion(+), 1 deletion(-)\n>>>>\n>>>> diff --git a/meson.build b/meson.build\n>>>> index 4aa7ecc96..1d8e1d994 100644\n>>>> --- a/meson.build\n>>>> +++ b/meson.build\n>>>> @@ -168,7 +168,7 @@ if cc.get_id() == 'gcc'\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>>>\n>>> Expanding the context:\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>>>\n>>> This would look odd compared to the version check below. We can't just\n>>> s/13/11/ as that wouldn't be correct, so we probably need to list both\n>>> versions with their corresponding behaviour.\n>>\n>> This is the behaviour of when object slicing in the return statement:\n>>\n>>        -std=c++17       -std=c++20\n>>     8:   move             move\n>>     9:   copy             copy\n>>    10:   copy             copy\n>>    11:   copy             move\n>>    12:   copy             move\n>>    13:   move             move\n>>    14:   move             move\n>>    15:   move             move\n>>\n>> Since GCC 8 is not supported. I think it is enough to just state that\n>> since GCC 11 automatic move happens when the object is sliced, which\n>> is I think the problematic case for libcamera.\n> \n> For the issue you're fixing here, yes, but we also have the current\n> issue that is separate and occurs with gcc <13. If we document the first\n> one only, we'll drop -Wno-redundant-move when dropping support for gcc\n> older than 11 and issues will occur with gcc older than 13. I suppose\n> they will be caught by CI though, so maybe it's OK?\n\nSorry, it seems I am confused. As far as I'm aware this warning is only disabled\nbecause of py_helpers.cpp:valueOrTuple(), which does object slicing in its return\nstatement. So as soon as the minimum supported gcc version becomes 13 or 11, respectively,\nthis warning can be enabled, and the redundant move can be removed. And everything\nshould work, no?\n\n\n\n> \n>>>> -    if cc.version().version_compare('>=13')\n>>>> +    if cc.version().version_compare('>=11')\n>>>>            cpp_arguments += [\n>>>>                '-Wno-redundant-move',\n>>>>            ]\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 6ED8FBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  9 Jan 2026 10:32:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 73744606D5;\n\tFri,  9 Jan 2026 11:32:21 +0100 (CET)","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 27516606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  9 Jan 2026 11:32:20 +0100 (CET)","from [192.168.33.17] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 08BA763B;\n\tFri,  9 Jan 2026 11:31:57 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QOoMLUwi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1767954717;\n\tbh=FAI3iCB0jT6qberP3xEs59LPUKmPTi2q5HctcOTSGHg=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=QOoMLUwibgWHLe4gOxQm33k5WD38zVLVOyLFxUNCRbFCpdt19yqmyb84mDisax6Ey\n\tSVD86408S5jG2dlkPOj824o18NrqhvaW86TtgOu0EFeMbZ00BvuQIc9Sh/xOgeCX9C\n\tZfS5+/FeaTlKLnvZWdbpcvKPssFLtN5cLb+tGv90=","Message-ID":"<18fe9503-c4e6-45a2-8984-08611ed7527e@ideasonboard.com>","Date":"Fri, 9 Jan 2026 11:32:16 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>","References":"<20260107193607.2168539-1-barnabas.pocze@ideasonboard.com>\n\t<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>\n\t<20260107202525.GF20168@pendragon.ideasonboard.com>\n\t<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>\n\t<20260109091948.GB20376@pendragon.ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260109091948.GB20376@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37627,"web_url":"https://patchwork.libcamera.org/comment/37627/","msgid":"<20260113222444.GD25101@pendragon.ideasonboard.com>","date":"2026-01-13T22:24:44","subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Jan 09, 2026 at 11:32:16AM +0100, Barnabás Pőcze wrote:\n> 2026. 01. 09. 10:19 keltezéssel, Laurent Pinchart írta:\n> > On Thu, Jan 08, 2026 at 10:05:25AM +0100, Barnabás Pőcze wrote:\n> >> 2026. 01. 07. 21:25 keltezéssel, Laurent Pinchart írta:\n> >>> On Wed, Jan 07, 2026 at 08:36:04PM +0100, Barnabás Pőcze wrote:\n> >>>> In C++20 mode, object slicing in a return statement triggers automatic move\n> >>>> since GCC 11, and using `std::move()` emits `-Wredundant-move` in those\n> >>>> same GCC versions. So disable the warning in those as well.\n> >>>\n> >>> Reading https://en.cppreference.com/w/cpp/language/return.html, do I\n> >>> understand correctly that in C++20 the following clause stops applying,\n> >>> and that's what causes the difference in behaviour due to the \"formally\"\n> >>> part ?\n> >>>\n> >>>     or it succeeded, but did not select the move constructor (formally,\n> >>>     the first parameter of the selected constructor was not an rvalue\n> >>>     reference to the (possibly cv-qualified) type of expression)\n> >>\n> >> I believe the relevant document is https://wg21.link/p1155r3#slicing\n> > \n> > Thanks, that matches my understanding. It must be tough writing a\n> > compiler, one needs a special mindset to adhere strictly to the spec\n> > instead of interpreting it in an optimized way.\n> > \n> >>>> This is relevant for `valueOrTuple()` in `py_helpers.cpp`, which\n> >>>> returns a `py::tuple` as `py::object`.\n> >>>>\n> >>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >>>> ---\n> >>>>    meson.build | 2 +-\n> >>>>    1 file changed, 1 insertion(+), 1 deletion(-)\n> >>>>\n> >>>> diff --git a/meson.build b/meson.build\n> >>>> index 4aa7ecc96..1d8e1d994 100644\n> >>>> --- a/meson.build\n> >>>> +++ b/meson.build\n> >>>> @@ -168,7 +168,7 @@ if cc.get_id() == 'gcc'\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> >>>\n> >>> Expanding the context:\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> >>>\n> >>> This would look odd compared to the version check below. We can't just\n> >>> s/13/11/ as that wouldn't be correct, so we probably need to list both\n> >>> versions with their corresponding behaviour.\n> >>\n> >> This is the behaviour of when object slicing in the return statement:\n> >>\n> >>        -std=c++17       -std=c++20\n> >>     8:   move             move\n> >>     9:   copy             copy\n> >>    10:   copy             copy\n> >>    11:   copy             move\n> >>    12:   copy             move\n> >>    13:   move             move\n> >>    14:   move             move\n> >>    15:   move             move\n> >>\n> >> Since GCC 8 is not supported. I think it is enough to just state that\n> >> since GCC 11 automatic move happens when the object is sliced, which\n> >> is I think the problematic case for libcamera.\n> > \n> > For the issue you're fixing here, yes, but we also have the current\n> > issue that is separate and occurs with gcc <13. If we document the first\n> > one only, we'll drop -Wno-redundant-move when dropping support for gcc\n> > older than 11 and issues will occur with gcc older than 13. I suppose\n> > they will be caught by CI though, so maybe it's OK?\n> \n> Sorry, it seems I am confused. As far as I'm aware this warning is only disabled\n> because of py_helpers.cpp:valueOrTuple(), which does object slicing in its return\n> statement. So as soon as the minimum supported gcc version becomes 13 or 11, respectively,\n> this warning can be enabled, and the redundant move can be removed. And everything\n> should work, no?\n\nYou're right, I thought we had more occurrences of the issue that were\nnot related to slicing. Let's then update the comment to refer to gcc 11\nand object slicing.\n\n        # Prior to gcc 11, object slicing in a return statement didn't perform\n\t# automatic move. It required explicit std::move() usage, which now\n\t# generate warnings. Those moves can't be removed as older compiler\n\t# versions could use copy constructors instead of move constructors. The\n\t# easiest fix is to disable the warning. With -Wpessimizing-move\n\t# enabled, the compiler will still warn of pessimizing moves, only the\n\t# redundant but not pessimizing moves will be ignored.\n\t#\n\t# \\todo When dropping support for compilers older than gcc 11, drop the\n\t# argument and remove the unneeded std::move() calls.\n\nYou could drop the \\todo if you think it's not necessary.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> >>>> -    if cc.version().version_compare('>=13')\n> >>>> +    if cc.version().version_compare('>=11')\n> >>>>            cpp_arguments += [\n> >>>>                '-Wno-redundant-move',\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 11279BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 22:25:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D399A61FBC;\n\tTue, 13 Jan 2026 23:25:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E99E61FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 23:25:05 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 05B4A3A4;\n\tTue, 13 Jan 2026 23:24:38 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"i5qZy4dA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768343079;\n\tbh=DqE0ZuhqmA92eoJttYwCek3stZnC5PuWR080K8FdCjU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=i5qZy4dAyvdRsbGqq5ix9xDGoHrJ7RVhT2wcE3jIJUiuJ7duMsxy9pQirkZw90LO/\n\t3KAs5Dr87Fi72gAxdJWjvM0++6e7oMyOEqEaTSU980PsiMoIXNeBKvcrD904sXWkgA\n\tgA0PQrahVeICP/wuyRTTq8n4jyPgR48rE+dwXZhE=","Date":"Wed, 14 Jan 2026 00:24:44 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"Re: [RFC PATCH v1 2/5] meson: Ignore `Wredundant-move` with GCC 11\n\tand above","Message-ID":"<20260113222444.GD25101@pendragon.ideasonboard.com>","References":"<20260107193607.2168539-1-barnabas.pocze@ideasonboard.com>\n\t<20260107193607.2168539-3-barnabas.pocze@ideasonboard.com>\n\t<20260107202525.GF20168@pendragon.ideasonboard.com>\n\t<016b6fc4-08b9-4c80-a787-22e4ed4db68b@ideasonboard.com>\n\t<20260109091948.GB20376@pendragon.ideasonboard.com>\n\t<18fe9503-c4e6-45a2-8984-08611ed7527e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<18fe9503-c4e6-45a2-8984-08611ed7527e@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]