{"id":18575,"url":"https://patchwork.libcamera.org/api/patches/18575/?format=json","web_url":"https://patchwork.libcamera.org/patch/18575/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230501025711.25157-1-laurent.pinchart@ideasonboard.com>","date":"2023-05-01T02:57:11","name":"[libcamera-devel] meson: Ignore -Wredundant-move with gcc-13 and newer","commit_ref":"af7d6a4c2df6c836ecc704ea44b39ea07418d832","pull_url":null,"state":"accepted","archived":false,"hash":"d0c9a28a4820e54e171df1f1ff7d0e9a5b5baa6e","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18575/mbox/","series":[{"id":3855,"url":"https://patchwork.libcamera.org/api/series/3855/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3855","date":"2023-05-01T02:57:11","name":"[libcamera-devel] meson: Ignore -Wredundant-move with gcc-13 and newer","version":1,"mbox":"https://patchwork.libcamera.org/series/3855/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18575/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18575/checks/","tags":{},"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 C99FDC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 May 2023 02:57:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 22320627DF;\n\tMon,  1 May 2023 04:57:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C90F6627D1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 May 2023 04:57:02 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 24F90A06;\n\tMon,  1 May 2023 04:56:59 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682909826;\n\tbh=0M8Ga/RpJJOEGe4DKwsDu5EjbHBzbcHUK4N1F0uZoWo=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=i8hsAJ3yR3G4lTQhB+GKqUeymcASb6tFr2Xivh1jbfO6aLFqJVU8CYYNLHrDhKZsI\n\tpbdo5ZSqWDf9Cirjrdk7nuQq15z75agfEmAtZmNZjd9/iARS+uIf4NPjSV9TeC9FuE\n\tlQAM7v+n9gfeCdmMzWVwyF1jfUOrLXJKUdmy0QoyiK6VH/TtbL8avADbGiwwDFoQjh\n\tGFJWEVzZHTQypcooUlTqbyrOv1snqAZGdtd+jSLePh9ON68YN9vKaZckhW1i3VfZHG\n\t1MzWs6W3tBr/nKH/ZZ0y+SVj8PvWG2O64mvBEk4jQIr9BDwZRioQivVzLYnOnTihWD\n\tKYKjoWhUZ+a1A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1682909821;\n\tbh=0M8Ga/RpJJOEGe4DKwsDu5EjbHBzbcHUK4N1F0uZoWo=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=ltmMoOgeN4ubeAYuWM30Rk2kAjFqWLZlZLJ07CFAOZBLFpot5LP13MQhI895M2abK\n\t7ycLXWtOoYLojXlRc1ZgJOXKw3vudZEKjOpGhZzl+DT3QeiJFUlPXgbHInxQDVnETC\n\tM26gng9FXY6N5tCFEAO9IFgZ2G7/3Y8V3rFCdkOQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ltmMoOge\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Starting from 13.1, gcc implements the C++23 version of automatic move\nfrom local variables in return statements (see\nhttps://en.cppreference.com/w/cpp/language/return). As a result, some\npreviously required explicit `std::move()` in return statements generate\nwarnings. This is the case when a function returns an object whose type\nis a class derived from the class type the function returns:\n\nstruct U { };\nstruct T : U { };\n\nU f()\n{\n\tT t;\n\treturn t;\n}\n\nUp to C++20, the automatic move from local variables selects the move\nconstructor of class U, which is not the move constructor of the\nexpression. Overload resolution is then performed a second time, with t\nconsidered as an lvalue. An explicit `std::move(t)` is needed in the\nreturn statement to select the U move constructor.\n\nStarting from C++23, `t` is treated as an xvalue, and the U move\nconstructor is selected without the need for an explicit `std::move(t)`.\nAn explicit `std:move()` then generates a redundant-move warning, as in\nthe valueOrTuple() function in src/py/libcamera/py_helpers.cpp.\n\nOmitting the `std::move()` silences the warning, but selects the copy\nconstructor of U with older gcc versions and with clang, which\nnegatively impacts performance.\n\nThe easiest fix is to disable the warning. With -Wpessimizing-move\nenabled, the compiler will still warn of pessimizing moves, only the\nredundant but not pessimizing moves will be ignored.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n meson.build | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\n\nbase-commit: 701b201cf387055e5c0a1c9549e2dbbf4988f092","diff":"diff --git a/meson.build b/meson.build\nindex 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","prefixes":["libcamera-devel"]}