[{"id":26788,"web_url":"https://patchwork.libcamera.org/comment/26788/","msgid":"<168002357384.765114.2730090820205171786@Monstersaurus>","date":"2023-03-28T17:12:53","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Eric,\n\nQuoting Eric Curtin (2023-02-20 04:55:24)\n> ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n>    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n>       |                                             ^~~~\n> ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n>    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n>       |                                                                                 ^\n> cc1plus: all warnings being treated as errors\n> \n> Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n\nI'm still hoping that holding off a little on this will ensure it's\nfixed in the compiler before GCC-13 is released - but I think I can also\nalready add:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nAnd given a fix was added to gcc-13, but it didn't fix /this/ we may be\ngetting to the point that we'll simply have to merge this. I guess it\ndepends on when gcc-13 is actually released?\n\n--\nKieran\n\n\n> ---\n> Changes in v3:\n> \n> - Added comment explaining change made because of false negative in gcc\n> \n> Changes in v2:\n> \n> - Added const\n> - Made patch mergeable by accounting for new directory structure\n> ---\n>  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n>  1 file changed, 9 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> index b32aad24..01846cdb 100644\n> --- a/src/apps/cam/file_sink.cpp\n> +++ b/src/apps/cam/file_sink.cpp\n> @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n>         }\n>  \n>         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> -\n> +               /*\n> +                * formerly \"const FrameMetadata::Plane &\" \n> +                * causing false negative (gcc 13):\n> +                * \"possibly dangling reference to a temporary\"\n> +                */\n> +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n>                 Span<uint8_t> data = image->data(i);\n> -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n>  \n> -               if (meta.bytesused > data.size())\n> -                       std::cerr << \"payload size \" << meta.bytesused\n> +               if (bytesused > data.size())\n> +                       std::cerr << \"payload size \" << bytesused\n>                                   << \" larger than plane size \" << data.size()\n>                                   << std::endl;\n>  \n> -- \n> 2.39.1\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 59C37C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Mar 2023 17:12:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F93762740;\n\tTue, 28 Mar 2023 19:12:57 +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 AF38961ECD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Mar 2023 19:12:56 +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 4457FDEE;\n\tTue, 28 Mar 2023 19:12:56 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680023577;\n\tbh=OzrrDUz6YR7ll7jyb/50+HoZIfHq/lW8k9aK8aCmG5c=;\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:Cc:\n\tFrom;\n\tb=GLrCjFe1V9suD1iu/HGl+hlFL0Yt7cM41e9weDwSbzZfol6B3G2epYPPLuNoub+cN\n\tFhO2LfNwN5M4y7vlfhCpw3baBGsx0vPkCc69f3Mm7bEah6GxgOce2lIhgnqwUAbPmx\n\tems1nQd2pkm/WeTesUsDXZFnENG4dXN6Cfo08zZDwrrvF5kVVmXTOjweNTIt1eT8Fc\n\tClGfoP8ZMfMP59pcpVJAy1Dn/Gk610mpkG4W6TO2kHPBHcKzCmLlJfr4AyQFZ7hu/R\n\traeOn6ndgiO1G9v/cfD5PFjJ7bqDbivQ7ww9Pp2Vm1ri/lvblCkQerlSpDx+Nfj9ku\n\t32GDYNH/CYDmw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1680023576;\n\tbh=OzrrDUz6YR7ll7jyb/50+HoZIfHq/lW8k9aK8aCmG5c=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=a0gPZa78iI2K7KMTIwURg0yeSBVONzyFkNDu0ZsLuO8Qtm+PjEqhe0zRwCTtvQ2LM\n\tRdsSmsEgJQ5TqysBuXntv31sIg1rFWKCG7kyKtYCgq3W8qgOrMDYPQsBRIk327NIhu\n\t1q/ZxIFrOBpp/yBFy+k2UaF8l7Vizc3MfRskawBY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"a0gPZa78\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20230220045523.3884-1-ecurtin@redhat.com>","References":"<20230220045523.3884-1-ecurtin@redhat.com>","To":"Eric Curtin <ecurtin@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Tue, 28 Mar 2023 18:12:53 +0100","Message-ID":"<168002357384.765114.2730090820205171786@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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>","Cc":"wtaymans@redhat.com, Khem Raj <raj.khem@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26789,"web_url":"https://patchwork.libcamera.org/comment/26789/","msgid":"<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>","date":"2023-03-28T17:26:58","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":62,"url":"https://patchwork.libcamera.org/api/people/62/","name":"Khem Raj","email":"raj.khem@gmail.com"},"content":"On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham\n<kieran.bingham@ideasonboard.com> wrote:\n>\n> Hi Eric,\n>\n> Quoting Eric Curtin (2023-02-20 04:55:24)\n> > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> >       |                                             ^~~~\n> > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> >       |                                                                                 ^\n> > cc1plus: all warnings being treated as errors\n> >\n> > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n>\n> I'm still hoping that holding off a little on this will ensure it's\n> fixed in the compiler before GCC-13 is released - but I think I can also\n> already add:\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> getting to the point that we'll simply have to merge this. I guess it\n> depends on when gcc-13 is actually released?\n\nIn a months time. It perhaps is not going to be fixed by atleast the\nfirst 13.x release. Maybe subsequent point releases\nmight have it\n\n>\n> --\n> Kieran\n>\n>\n> > ---\n> > Changes in v3:\n> >\n> > - Added comment explaining change made because of false negative in gcc\n> >\n> > Changes in v2:\n> >\n> > - Added const\n> > - Made patch mergeable by accounting for new directory structure\n> > ---\n> >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> >  1 file changed, 9 insertions(+), 5 deletions(-)\n> >\n> > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > index b32aad24..01846cdb 100644\n> > --- a/src/apps/cam/file_sink.cpp\n> > +++ b/src/apps/cam/file_sink.cpp\n> > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> >         }\n> >\n> >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > -\n> > +               /*\n> > +                * formerly \"const FrameMetadata::Plane &\"\n> > +                * causing false negative (gcc 13):\n> > +                * \"possibly dangling reference to a temporary\"\n> > +                */\n> > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> >                 Span<uint8_t> data = image->data(i);\n> > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> >\n> > -               if (meta.bytesused > data.size())\n> > -                       std::cerr << \"payload size \" << meta.bytesused\n> > +               if (bytesused > data.size())\n> > +                       std::cerr << \"payload size \" << bytesused\n> >                                   << \" larger than plane size \" << data.size()\n> >                                   << std::endl;\n> >\n> > --\n> > 2.39.1\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 DA93BBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Mar 2023 17:27:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 384646271F;\n\tTue, 28 Mar 2023 19:27:28 +0200 (CEST)","from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com\n\t[IPv6:2607:f8b0:4864:20::c2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F5A861ECD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Mar 2023 19:27:26 +0200 (CEST)","by mail-oo1-xc2e.google.com with SMTP id\n\tn3-20020a4ad403000000b0053351dadc20so1990166oos.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Mar 2023 10:27:26 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680024448;\n\tbh=xyCzMcgDGFFUKDN4mHwpRpggYKf9cQIJBwmSPd5lrSE=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ywCRxhTZnz35TX+GL/tx3K544g718ikx2TsVI+lOeSk1hmJ3Ybyj1jeGH5tnZtRcX\n\te0SNxbZB+pw/9m+a0nd+czUP5TFXQzu98h8ggJdHUd2XDzGnvrXYzvPAAF0h0F8Ej0\n\tJayt3z+OwxDiPi+yclVHLC0o6gK2c1kjDLWA8Cn0BOSTSna9qOlezoK+Tit6gKyf/a\n\tR1Kiospo8Pyh6nAztksh0FbJkLvmn62irSVDbLJAyqS2iwuI5rikJVK+UPaHMrb75J\n\tFU++CSuyOo4a77sSrpvLdVVCwAaVsOTbI4o0gfkXEjv0VCMo4/UF1zyC91MWJS+EsU\n\tEQnwPvI524Jaw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20210112; t=1680024445;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=AUtnN8ao7/B+aYMtLxF9sS+6f/WZ7G5Cr1Xun/9uiNQ=;\n\tb=n/So7w6mri7SeOGvFyDLpURz6EwWJ7B+QFGHehscBJvHd/3w/IqSHmX/NnGavBgOeL\n\t4LY7N7SJjqwzPKPEDeEcUmLbkjL5llnvrFDi3HKcAl2XFC6xSQbcIwWodBYFQl31me5n\n\ttansqr3aaGX8mlaF3Oq+UjXTpcStWy4GFY9L4dloQcU5pNW/NO3DpIji8QzYBT2qzK0E\n\tWVPEaw/XbCczMB32pDxY/mfbmGkyX5FVeBDdAyCKuDvb6LPTQOxJD4Ft++kNZxcMCECK\n\tHJD2rNYnwfSQBiS/+4S2wms5Zu3bdvWUSKdsJy167f4feUZqgyRoVwWt3sClUcA9uRm0\n\tzHyw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"n/So7w6m\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680024445;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=AUtnN8ao7/B+aYMtLxF9sS+6f/WZ7G5Cr1Xun/9uiNQ=;\n\tb=t02fqqdMt9grGHpALVC41B6fcVDAAd47GIuMhD4CLHhg3GEeGg7jHOG/I8D5esvNxC\n\tZqLD3GBmNRKl2n8lI1Y/HjkQUaO94dAYfZ5a9OjCQaKF0jWMxfF1H4opTGmY59S3kFV8\n\tQiUfdZ3D3rlv4lZYD+nHDu5be31GimbzPtIc6ZHB88OJs8yVJqHt1j3tA/y/BI+AxIuL\n\tuEH/lqnR52U1UwQSI4FYCzLF0xMFVTcBn/OaoBzK/t3W2tki/GRU4jQeF7RrFmI4DVJH\n\tINRi2r0+h1+iUP7BOhcsj2KCL8udATu8sTTKV+pxLk5VSCosRKbYrHrgT/MWWSO8R8+t\n\t1qtQ==","X-Gm-Message-State":"AO0yUKXmZ3GLtTpr3bK0Xq65f2m/KjfqEQWa12yH8LFtlv/YPG35tVGq\n\tC03D9fv2cDV5JE8jP1gdAslTFcIwRGzo6BbhwZ4=","X-Google-Smtp-Source":"AK7set8JWn0jPHxztkJFDIEMmfsIlMmS/V9M4JVWfSUaczB2TDtcIT/oBBh4nxlyAQzrWFa4BPG7PZp6XL1rN2AG2W4=","X-Received":"by 2002:a4a:cb08:0:b0:53b:4eb9:205a with SMTP id\n\tr8-20020a4acb08000000b0053b4eb9205amr5753287ooq.0.1680024445019;\n\tTue, 28 Mar 2023 10:27:25 -0700 (PDT)","MIME-Version":"1.0","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>","In-Reply-To":"<168002357384.765114.2730090820205171786@Monstersaurus>","Date":"Tue, 28 Mar 2023 10:26:58 -0700","Message-ID":"<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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":"Khem Raj via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Khem Raj <raj.khem@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org, wtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26877,"web_url":"https://patchwork.libcamera.org/comment/26877/","msgid":"<20230413110702.GA11253@pendragon.ideasonboard.com>","date":"2023-04-13T11:07:02","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > >       |                                             ^~~~\n> > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > >       |                                                                                 ^\n> > > cc1plus: all warnings being treated as errors\n> > >\n> > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> >\n> > I'm still hoping that holding off a little on this will ensure it's\n> > fixed in the compiler before GCC-13 is released - but I think I can also\n> > already add:\n> >\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >\n> > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > getting to the point that we'll simply have to merge this. I guess it\n> > depends on when gcc-13 is actually released?\n> \n> In a months time. It perhaps is not going to be fixed by atleast the\n> first 13.x release. Maybe subsequent point releases\n> might have it\n\nIt looks like this won't be fixed in gcc :-(\n\nhttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n\nTheir recommendation is to use a pragma to disable the warning:\n\ndiff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\nindex b32aad247b8b..5fb075261a18 100644\n--- a/src/apps/cam/file_sink.cpp\n+++ b/src/apps/cam/file_sink.cpp\n@@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n \t}\n\n \tfor (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n \t\tconst FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n+#pragma GCC diagnostic pop\n\n \t\tSpan<uint8_t> data = image->data(i);\n \t\tunsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n\n> > > ---\n> > > Changes in v3:\n> > >\n> > > - Added comment explaining change made because of false negative in gcc\n> > >\n> > > Changes in v2:\n> > >\n> > > - Added const\n> > > - Made patch mergeable by accounting for new directory structure\n> > > ---\n> > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > >\n> > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > index b32aad24..01846cdb 100644\n> > > --- a/src/apps/cam/file_sink.cpp\n> > > +++ b/src/apps/cam/file_sink.cpp\n> > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > >         }\n> > >\n> > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > -\n> > > +               /*\n> > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > +                * causing false negative (gcc 13):\n> > > +                * \"possibly dangling reference to a temporary\"\n> > > +                */\n> > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > >                 Span<uint8_t> data = image->data(i);\n> > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > >\n> > > -               if (meta.bytesused > data.size())\n> > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > +               if (bytesused > data.size())\n> > > +                       std::cerr << \"payload size \" << bytesused\n> > >                                   << \" larger than plane size \" << data.size()\n> > >                                   << std::endl;\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 648BEC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 11:06:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 743C9627B8;\n\tThu, 13 Apr 2023 13:06:55 +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 B175C61EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 13:06:53 +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 554F0886;\n\tThu, 13 Apr 2023 13:06:50 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681384015;\n\tbh=hq3MEtSFquUM8VqL4IhUWC/1YdJ5uOHtkEZ8rpYTc4I=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=fmU0sXj5TQECE79yu92av18qoJMQqUOr7zm0Zzr2hlKAnUqYz/PlJHbqLkuYwgGVN\n\tiutmneWmPDj/SxNQOpcWe8ZzgWiqO4usTnzNfsh3WIL7amTb2Ud7gNignMDWtna25t\n\tuT7mIw8nZPoxHAqTT7Lz7boZJdhkR6Mc9jeaGD9+nwiywDz/5QxTykUAmkx/igW8je\n\t3GU9Qkx7X0eeM//AbSRRq3H5N5HsQ0Zg9GIkoNWVp4iwrkFOyNG3bcgUGDt2qiuxxL\n\t+sVvzR3cdvcfHpjbXA65HpQWTYcTu081U2QmAhOVQ3JD/IBqv6kRO/4/pTRtr+jIku\n\tkckuFTVU5pvaQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681384010;\n\tbh=hq3MEtSFquUM8VqL4IhUWC/1YdJ5uOHtkEZ8rpYTc4I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X3xmikr1LoEME9r3rTS7JrrEsuuJS/HrlQtRj+PEcS7e6dPJi4K9VFPs/GIKUSXy3\n\tcenxydnBvBSBGHfXT8hzY5DXdJs/5DIT56QAvouMH1C3cUvEbtiWsV8M6Lbc7yUtaf\n\txOihsGRmCS4yF+3aDyqz/ei6wcurX+yZHGujO7oQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"X3xmikr1\"; dkim-atps=neutral","Date":"Thu, 13 Apr 2023 14:07:02 +0300","To":"Khem Raj <raj.khem@gmail.com>","Message-ID":"<20230413110702.GA11253@pendragon.ideasonboard.com>","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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>","Cc":"libcamera-devel@lists.libcamera.org, wtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26878,"web_url":"https://patchwork.libcamera.org/comment/26878/","msgid":"<168138439955.3536995.11061677505792244340@Monstersaurus>","date":"2023-04-13T11:13:19","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > >       |                                             ^~~~\n> > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > >       |                                                                                 ^\n> > > > cc1plus: all warnings being treated as errors\n> > > >\n> > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > >\n> > > I'm still hoping that holding off a little on this will ensure it's\n> > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > already add:\n> > >\n> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > >\n> > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > getting to the point that we'll simply have to merge this. I guess it\n> > > depends on when gcc-13 is actually released?\n> > \n> > In a months time. It perhaps is not going to be fixed by atleast the\n> > first 13.x release. Maybe subsequent point releases\n> > might have it\n> \n> It looks like this won't be fixed in gcc :-(\n> \n> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> \n> Their recommendation is to use a pragma to disable the warning:\n> \n> diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> index b32aad247b8b..5fb075261a18 100644\n> --- a/src/apps/cam/file_sink.cpp\n> +++ b/src/apps/cam/file_sink.cpp\n> @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n>         }\n> \n>         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> +#pragma GCC diagnostic push\n> +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n>                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> +#pragma GCC diagnostic pop\n> \n>                 Span<uint8_t> data = image->data(i);\n>                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n\nI think I'd prefer to apply the patch suggested here than add a pragma!\n\nLaurent, any objection? Lets get this resolved quickly now we know it's\nnot going to be fixed in gcc.\n\n--\nKieran\n\n\n> \n> > > > ---\n> > > > Changes in v3:\n> > > >\n> > > > - Added comment explaining change made because of false negative in gcc\n> > > >\n> > > > Changes in v2:\n> > > >\n> > > > - Added const\n> > > > - Made patch mergeable by accounting for new directory structure\n> > > > ---\n> > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > >\n> > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > index b32aad24..01846cdb 100644\n> > > > --- a/src/apps/cam/file_sink.cpp\n> > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > >         }\n> > > >\n> > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > -\n> > > > +               /*\n> > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > +                * causing false negative (gcc 13):\n> > > > +                * \"possibly dangling reference to a temporary\"\n> > > > +                */\n> > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > >                 Span<uint8_t> data = image->data(i);\n> > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > >\n> > > > -               if (meta.bytesused > data.size())\n> > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > +               if (bytesused > data.size())\n> > > > +                       std::cerr << \"payload size \" << bytesused\n> > > >                                   << \" larger than plane size \" << data.size()\n> > > >                                   << std::endl;\n> > > >\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 1EA12BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 11:13:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F6D8627B1;\n\tThu, 13 Apr 2023 13:13:23 +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 0E15561EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 13:13:22 +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 56ABA886;\n\tThu, 13 Apr 2023 13:13:19 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681384403;\n\tbh=inh0gONxOWFmY4AVj//7K7z0zXuFc5UN4oSbUdUuuyM=;\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:Cc:\n\tFrom;\n\tb=effkQ02nVft5urZWU0ULjZmo8OaWE4NLZlkawVjEa+K1XqN2tsMOrip24jf04bO4f\n\tc8QLjCBQ/XQHBx49pKu9YqjwJS50kCQD/EoYGQubgZ9SAu5M8KUvJr3fDl8ZmRPkHd\n\tS2yU1XTLxgCTNRWXI6j7L8rZEHiWlHTe4sDHOZyMif1zwG+2kXGNKGdEZ13JlKIi+k\n\tvcO1K5IXPVamvaJxBa6ZAfxsnKu04o7BkkW4C/hyoJCmmEMfzL9Au0GnUHyIkik8dW\n\tce4X0l6pi3sIWZC2vpSyx6UcVbQqZ2EJiMab4ElzxISpgv1WX04Vt9f9UyZJE5tAKY\n\tJpUBvBSGtIV1Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681384399;\n\tbh=inh0gONxOWFmY4AVj//7K7z0zXuFc5UN4oSbUdUuuyM=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=uyhknRqHNrHJOkz5+Uvr/RuDAZH7V+239Jk/6s0S48GmLXaj/I2nRcPdS1VCpa5uI\n\tyNM5UvzOLUdwBREp/leZUJjCx9ID+esYUtbT8UkK2jK2852tYjzlOCBk+RPdK2v+Wh\n\t/3G+Jdx8UD5m6bQTPMntp9GGG/RXe2pHiiIfjh9I="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"uyhknRqH\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20230413110702.GA11253@pendragon.ideasonboard.com>","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>","To":"Khem Raj <raj.khem@gmail.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Thu, 13 Apr 2023 12:13:19 +0100","Message-ID":"<168138439955.3536995.11061677505792244340@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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>","Cc":"libcamera-devel@lists.libcamera.org, wtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26879,"web_url":"https://patchwork.libcamera.org/comment/26879/","msgid":"<CAOgh=FwBOAhACehrzM+TL0PcGz-rGgL5tOq5Opdz9c1vhs1+jw@mail.gmail.com>","date":"2023-04-13T11:35:53","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/","name":"Eric Curtin","email":"ecurtin@redhat.com"},"content":"On Thu, 13 Apr 2023 at 12:13, Kieran Bingham\n<kieran.bingham@ideasonboard.com> wrote:\n>\n> Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> > On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > >       |                                             ^~~~\n> > > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > >       |                                                                                 ^\n> > > > > cc1plus: all warnings being treated as errors\n> > > > >\n> > > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > >\n> > > > I'm still hoping that holding off a little on this will ensure it's\n> > > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > > already add:\n> > > >\n> > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > >\n> > > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > > getting to the point that we'll simply have to merge this. I guess it\n> > > > depends on when gcc-13 is actually released?\n> > >\n> > > In a months time. It perhaps is not going to be fixed by atleast the\n> > > first 13.x release. Maybe subsequent point releases\n> > > might have it\n> >\n> > It looks like this won't be fixed in gcc :-(\n> >\n> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> >\n> > Their recommendation is to use a pragma to disable the warning:\n> >\n> > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > index b32aad247b8b..5fb075261a18 100644\n> > --- a/src/apps/cam/file_sink.cpp\n> > +++ b/src/apps/cam/file_sink.cpp\n> > @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> >         }\n> >\n> >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > +#pragma GCC diagnostic push\n> > +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n> >                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > +#pragma GCC diagnostic pop\n> >\n> >                 Span<uint8_t> data = image->data(i);\n> >                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n>\n> I think I'd prefer to apply the patch suggested here than add a pragma!\n\nI prefer the patch here also for the record, more portable code (even\nthough that may not be an issue for libcamera), could add a comment or\nsomething (but do we care enough?).\n\nBut whatever you guys think :)\n\n>\n> Laurent, any objection? Lets get this resolved quickly now we know it's\n> not going to be fixed in gcc.\n>\n> --\n> Kieran\n>\n>\n> >\n> > > > > ---\n> > > > > Changes in v3:\n> > > > >\n> > > > > - Added comment explaining change made because of false negative in gcc\n> > > > >\n> > > > > Changes in v2:\n> > > > >\n> > > > > - Added const\n> > > > > - Made patch mergeable by accounting for new directory structure\n> > > > > ---\n> > > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > > >\n> > > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > > index b32aad24..01846cdb 100644\n> > > > > --- a/src/apps/cam/file_sink.cpp\n> > > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > > >         }\n> > > > >\n> > > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > -\n> > > > > +               /*\n> > > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > > +                * causing false negative (gcc 13):\n> > > > > +                * \"possibly dangling reference to a temporary\"\n> > > > > +                */\n> > > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > > >                 Span<uint8_t> data = image->data(i);\n> > > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > > >\n> > > > > -               if (meta.bytesused > data.size())\n> > > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > > +               if (bytesused > data.size())\n> > > > > +                       std::cerr << \"payload size \" << bytesused\n> > > > >                                   << \" larger than plane size \" << data.size()\n> > > > >                                   << std::endl;\n> > > > >\n> >\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 6C8F9C0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 11:36:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 97B5E627B8;\n\tThu, 13 Apr 2023 13:36:14 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 97AB461EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 13:36:12 +0200 (CEST)","from mail-ua1-f71.google.com (mail-ua1-f71.google.com\n\t[209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-670-IR090PkwNDmZBVLwmZ_oWQ-1; Thu, 13 Apr 2023 07:36:10 -0400","by mail-ua1-f71.google.com with SMTP id\n\ty3-20020ab05b83000000b00760f945d47bso7996666uae.16\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 04:36:10 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681385774;\n\tbh=JFZ7rPhle67up3nI91XqMBlWl5m0OWUjHojn2qjqhnY=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=h9ISE7tihcMR+MhRP/FiCdaRKm88aIjb8+aJszOpLimYMcY0CUUD+4oXaNA38QPp6\n\tFpFbQO/DhzlaMugnBqtAQBWGX7pDsKurnlOQgDJEdMUYMQSjNjKWaIDu/UiQicpnnS\n\tNZ1wQdmLZe8ej7Mr3zbTV9nU+IWd3by7FHyy0NPzw6iujsOBG6XUZs5TbL+oiSb2+h\n\tmT+Ksd4j5v4aIk8ed5XpqRre6yN8puIMWIIBnUMdh9QwyEoRL18nOG3s2AiXy+6HBT\n\thE7MZ75lp7aQ6/6mdloYGsArm6l0HOSTJ01MYxT+2wDIs4cGdKzZYKgdcCIeS0NpAW\n\t+rXtJA2jTJnJg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1681385771;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=teCCWmUKFuw3Vm1/nQlisz0sDdAW2/afdh7i6qSm7QA=;\n\tb=R1cNq3Ne/3PxSV1pu3Q3CKXJnwVCZIS3uIbck2lp5ZSt2OBPxx43eI+pVGWxhfx2yPAkn4\n\tPxyA1Vfnf9F0u6yBHYwKWNMxcGlZGhrOaW+RRq712WgYA5verF9P39076+nU2kZoRfEfYe\n\tgh1/ZZ+KkCxVfeNJCIMGBXrKV7rdzZ4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"R1cNq3Ne\"; \n\tdkim-atps=neutral","X-MC-Unique":"IR090PkwNDmZBVLwmZ_oWQ-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1681385770; x=1683977770;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=teCCWmUKFuw3Vm1/nQlisz0sDdAW2/afdh7i6qSm7QA=;\n\tb=lekHZecddXPjZKUj71CxQVY7mxlWY76eTZ8h1Tt5JygKuWhCUh2Fr368C5enxKewkO\n\thz7P/nY2Usuz13/0XYbg5laM+crGd1YGTCBL73AMphKvGwGqCB8IFARLZtGhC1io/ptD\n\tHws+njZNBk6st4uiM5kMLW+XV/tEcd+z9NJ9O10QiubkDX0zvvp/R+m6mV/RzDAlELUl\n\tA9EW82slAnQ4iB5gPJvyzQXHJbCcIxJzoXUkMyzCaTngkEYANwDlZJvoWwxUpJuawvYk\n\tAzTPtkrkPiM8sKhJSV3V8/XRT4UoCJ60jm3GJ4+Z+y47GtePY3NCWyr9RjL60OCZIexw\n\tESzA==","X-Gm-Message-State":"AAQBX9fNRkfI020WIySid2Nm7rx4+Z3ID2Qfl9OojYP98zn/7vEz+l1r\n\tc1afgzbe4IO4twzIxN5ykj6jUo14+3h4FlsuyvgQD8c6MXbD34ZN6rVZtSLkK+A8QOik1BTOwjZ\n\toaeU+8ZdPzLoUtlNtlpgwlqAOWLh4TfYgEsLpjpuzRFpSF7u3PQ==","X-Received":["by 2002:a67:cb84:0:b0:42e:3737:a4de with SMTP id\n\th4-20020a67cb84000000b0042e3737a4demr113020vsl.3.1681385769804; \n\tThu, 13 Apr 2023 04:36:09 -0700 (PDT)","by 2002:a67:cb84:0:b0:42e:3737:a4de with SMTP id\n\th4-20020a67cb84000000b0042e3737a4demr113005vsl.3.1681385769474;\n\tThu, 13 Apr 2023 04:36:09 -0700 (PDT)"],"X-Google-Smtp-Source":"AKy350aET5f4fLTCA7SuEmuxB7nsu59Ryc16xL48XSI2WEhVr9ewz9I0FSUC/A9rDQFYbv+imzxjNJmP9AkTE9HKKIM=","MIME-Version":"1.0","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>\n\t<168138439955.3536995.11061677505792244340@Monstersaurus>","In-Reply-To":"<168138439955.3536995.11061677505792244340@Monstersaurus>","Date":"Thu, 13 Apr 2023 12:35:53 +0100","Message-ID":"<CAOgh=FwBOAhACehrzM+TL0PcGz-rGgL5tOq5Opdz9c1vhs1+jw@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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":"Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Eric Curtin <ecurtin@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org, Khem Raj <raj.khem@gmail.com>,\n\twtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26880,"web_url":"https://patchwork.libcamera.org/comment/26880/","msgid":"<20230413113710.GA23208@pendragon.ideasonboard.com>","date":"2023-04-13T11:37:10","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Apr 13, 2023 at 12:13:19PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> > On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > >       |                                             ^~~~\n> > > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > >       |                                                                                 ^\n> > > > > cc1plus: all warnings being treated as errors\n> > > > >\n> > > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > >\n> > > > I'm still hoping that holding off a little on this will ensure it's\n> > > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > > already add:\n> > > >\n> > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > >\n> > > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > > getting to the point that we'll simply have to merge this. I guess it\n> > > > depends on when gcc-13 is actually released?\n> > > \n> > > In a months time. It perhaps is not going to be fixed by atleast the\n> > > first 13.x release. Maybe subsequent point releases\n> > > might have it\n> > \n> > It looks like this won't be fixed in gcc :-(\n> > \n> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> > \n> > Their recommendation is to use a pragma to disable the warning:\n> > \n> > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > index b32aad247b8b..5fb075261a18 100644\n> > --- a/src/apps/cam/file_sink.cpp\n> > +++ b/src/apps/cam/file_sink.cpp\n> > @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> >         }\n> > \n> >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > +#pragma GCC diagnostic push\n> > +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n> >                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > +#pragma GCC diagnostic pop\n> > \n> >                 Span<uint8_t> data = image->data(i);\n> >                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> \n> I think I'd prefer to apply the patch suggested here than add a pragma!\n> \n> Laurent, any objection? Lets get this resolved quickly now we know it's\n> not going to be fixed in gcc.\n\nThere are pros and cons (as always). The pragma is self-documenting,\nwhich I like. Even with the comment below, future refactoring may\nreintroduce the problem.\n\n> > > > > ---\n> > > > > Changes in v3:\n> > > > >\n> > > > > - Added comment explaining change made because of false negative in gcc\n> > > > >\n> > > > > Changes in v2:\n> > > > >\n> > > > > - Added const\n> > > > > - Made patch mergeable by accounting for new directory structure\n> > > > > ---\n> > > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > > >\n> > > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > > index b32aad24..01846cdb 100644\n> > > > > --- a/src/apps/cam/file_sink.cpp\n> > > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > > >         }\n> > > > >\n> > > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > -\n> > > > > +               /*\n> > > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > > +                * causing false negative (gcc 13):\n> > > > > +                * \"possibly dangling reference to a temporary\"\n> > > > > +                */\n> > > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > > >                 Span<uint8_t> data = image->data(i);\n> > > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > > >\n> > > > > -               if (meta.bytesused > data.size())\n> > > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > > +               if (bytesused > data.size())\n> > > > > +                       std::cerr << \"payload size \" << bytesused\n> > > > >                                   << \" larger than plane size \" << data.size()\n> > > > >                                   << std::endl;\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 C362CC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 11:37:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D9FA627B7;\n\tThu, 13 Apr 2023 13:37:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C362961EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 13:37:00 +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 2BDCAD20;\n\tThu, 13 Apr 2023 13:36:56 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681385822;\n\tbh=Qw3Xyaq7gyUS1sCjUW6glUees8YgG5v4Sb+gYH0vKN8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=JYkkSnh03agRnsmtfHG1A5fsqABAA4XZ9c+nxn5GG8rmlQw84KJfOv+fyIDWQ5h/T\n\tFV/2ifQiD7XSpueTW0uB0kXhHZEo++BI3mEGO0x82MLm6xVJWFj7PfK6V4O/WdJSIv\n\tsd2PYBAFVGd/V2CPf77oVn2CFYneuoJ+zmM6xZ2x4a9Kpk7vzKdOosuOphJUxYncf3\n\tNue/n50WsHdomJL2wKZcYDVwfGiaTePzgF3GYLpVqAs900TfGLbpuQ6F1ocYL8lW6f\n\t6GI3FYJUvS5gDSVPAacjeObscLnNxay6onZK94ZSwpch0xIY4MINOtucl6SQFCKfQF\n\tqiuwsvoUyX8EQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681385818;\n\tbh=Qw3Xyaq7gyUS1sCjUW6glUees8YgG5v4Sb+gYH0vKN8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=E/b+q5C+ckAVEZVeV1hhvR5+Iipzg5gtakWV2T0924rNs5CayPI295YYno0ze4Jv4\n\tLnIgf2eftG7i7a0wl2kNnGWzAZ55hY9/7JnYQw9T94/qLOX18e9+VP7lTZVRhjcVbu\n\tRhJUref8LvKOJYiMilE/Pod9xU77+YAVCwifVtzQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"E/b+q5C+\"; dkim-atps=neutral","Date":"Thu, 13 Apr 2023 14:37:10 +0300","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20230413113710.GA23208@pendragon.ideasonboard.com>","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>\n\t<168138439955.3536995.11061677505792244340@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<168138439955.3536995.11061677505792244340@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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>","Cc":"libcamera-devel@lists.libcamera.org, Khem Raj <raj.khem@gmail.com>,\n\twtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26881,"web_url":"https://patchwork.libcamera.org/comment/26881/","msgid":"<CAOgh=FyDUAOefv=BMmMbWtQbtBHZ6j7voU3GU32XmhnE9JPa+Q@mail.gmail.com>","date":"2023-04-13T11:37:16","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/","name":"Eric Curtin","email":"ecurtin@redhat.com"},"content":"On Thu, 13 Apr 2023 at 12:35, Eric Curtin <ecurtin@redhat.com> wrote:\n>\n> On Thu, 13 Apr 2023 at 12:13, Kieran Bingham\n> <kieran.bingham@ideasonboard.com> wrote:\n> >\n> > Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> > > On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > > > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                             ^~~~\n> > > > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                                                                 ^\n> > > > > > cc1plus: all warnings being treated as errors\n> > > > > >\n> > > > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > > >\n> > > > > I'm still hoping that holding off a little on this will ensure it's\n> > > > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > > > already add:\n> > > > >\n> > > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > > >\n> > > > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > > > getting to the point that we'll simply have to merge this. I guess it\n> > > > > depends on when gcc-13 is actually released?\n> > > >\n> > > > In a months time. It perhaps is not going to be fixed by atleast the\n> > > > first 13.x release. Maybe subsequent point releases\n> > > > might have it\n> > >\n> > > It looks like this won't be fixed in gcc :-(\n> > >\n> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> > >\n> > > Their recommendation is to use a pragma to disable the warning:\n> > >\n> > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > index b32aad247b8b..5fb075261a18 100644\n> > > --- a/src/apps/cam/file_sink.cpp\n> > > +++ b/src/apps/cam/file_sink.cpp\n> > > @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > >         }\n> > >\n> > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > +#pragma GCC diagnostic push\n> > > +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n> > >                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > +#pragma GCC diagnostic pop\n> > >\n> > >                 Span<uint8_t> data = image->data(i);\n> > >                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> >\n> > I think I'd prefer to apply the patch suggested here than add a pragma!\n>\n> I prefer the patch here also for the record, more portable code (even\n> though that may not be an issue for libcamera), could add a comment or\n> something (but do we care enough?).\n\nScratch the we \"could add a comment\", it's there already.\n\nIt's so long since I submitted this patch I forgot!\n\nIs mise le meas/Regards,\n\nEric Curtin\n\n>\n> But whatever you guys think :)\n>\n> >\n> > Laurent, any objection? Lets get this resolved quickly now we know it's\n> > not going to be fixed in gcc.\n> >\n> > --\n> > Kieran\n> >\n> >\n> > >\n> > > > > > ---\n> > > > > > Changes in v3:\n> > > > > >\n> > > > > > - Added comment explaining change made because of false negative in gcc\n> > > > > >\n> > > > > > Changes in v2:\n> > > > > >\n> > > > > > - Added const\n> > > > > > - Made patch mergeable by accounting for new directory structure\n> > > > > > ---\n> > > > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > > > >\n> > > > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > > > index b32aad24..01846cdb 100644\n> > > > > > --- a/src/apps/cam/file_sink.cpp\n> > > > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > > > >         }\n> > > > > >\n> > > > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > > -\n> > > > > > +               /*\n> > > > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > > > +                * causing false negative (gcc 13):\n> > > > > > +                * \"possibly dangling reference to a temporary\"\n> > > > > > +                */\n> > > > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > > > >                 Span<uint8_t> data = image->data(i);\n> > > > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > > > >\n> > > > > > -               if (meta.bytesused > data.size())\n> > > > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > > > +               if (bytesused > data.size())\n> > > > > > +                       std::cerr << \"payload size \" << bytesused\n> > > > > >                                   << \" larger than plane size \" << data.size()\n> > > > > >                                   << std::endl;\n> > > > > >\n> > >\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 4A02BBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 11:37:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 01507627B7;\n\tThu, 13 Apr 2023 13:37:38 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2782C627B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 13:37:36 +0200 (CEST)","from mail-ua1-f69.google.com (mail-ua1-f69.google.com\n\t[209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-627-Bmf9AXHPOwGbW3w862hAEA-1; Thu, 13 Apr 2023 07:37:34 -0400","by mail-ua1-f69.google.com with SMTP id\n\tn11-20020ab0540b000000b007654e97787cso4467821uaa.17\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 04:37:33 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681385858;\n\tbh=wqsL3XJapWvwauGkwZE+23IEBC6CjkbZbYuv8ZYBiOQ=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Ywkt8Q0mguPuWRix4FrwpoawxqQjF1PtKLVYhBtGTQ6Vnn/iIMHUyZpBVKLaVYVjL\n\txs/U/SyfxaaNrFkGilpvumfuCk4b8GYiC/Y/krEDY6IwbYBF5J37kgYlf7nHRiSgbS\n\t3wzc8Ofj4a+kpbtOBEN+AsUKzqOnJJMynxuONTNTcjwZfNyF0GqaMRcu8O2fZldGUd\n\trvviXGp5r1hw6TZzqCHZQC9a72YXmxDJ9gATQOlpkya+RdmkZ0vp0GWQikrI8sbrCV\n\tMgQ0zrYT+OEe2+b+jCEttAwapUsBTlhbykoYVbNRaOMcK2AsFkqBGs3H8SIJXVwe3x\n\t5A5MaK6zXfaJw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1681385854;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=3Qpm7xdOtSsQ2rN8Wfa+NjZGflRWYBi+RntEcH4W++I=;\n\tb=QVv7yOLK/eFaY1rskYRLnCTDCyEZUKhw95w2ngrDBdptL4pQfV8uwWxi0w5TgOA7Mkk+8l\n\t2/yzQS5N0hJT5j+CgcNgCDiOQZ3prWfQguzmIYLdI3feK9XjyiTmDNm/HXr8Db7OpXM8bM\n\tXa7pd9d850Gbbe9mOm1OnkCmYtBqrO0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"QVv7yOLK\"; \n\tdkim-atps=neutral","X-MC-Unique":"Bmf9AXHPOwGbW3w862hAEA-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1681385853; x=1683977853;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=3Qpm7xdOtSsQ2rN8Wfa+NjZGflRWYBi+RntEcH4W++I=;\n\tb=HlDf+qOerhRyRHsHsgKLw4MfgdDrDrt8odxf1/wpjeNh7bEaNibreJEIIHRwfo7ECz\n\tC0JwAfZy/EE+YUQgmrUT/Q5Kax79EpBXvIgllcEwDroebnl/2bqteA4vPsDL6ftyn+M+\n\trP1rcev2ucGRowIlxRoZUVoYDaDHQm0eyykc1yvDtqa9dQ/cocBGoFS1T9/HCuj3JNiV\n\tknbicXN7ysIpW/XHYz3iFNqTyuWxk59BO3toYLVgBeWgAiN+TGGgQmHdxbc69GSsxkYw\n\ts+gSmTOFyfK+1xHGodkgsVYW+IOYi2dceU74dpbGfksw4xE7FAKwbBikExU2FALzwGXy\n\t0QnQ==","X-Gm-Message-State":"AAQBX9dpsiIQPddjSsiPcUjrVAafZ32GTvG4V7OQd5PMQ+A3NaRGM4yU\n\tNtuDMYm9fvO+9KpOfmqvjlbgoaxAP8lh6CmjzARGcz305MRQroVboQgU3OqxYXiNW3V+gmrC5jj\n\tpZet8hol48txWhnERE+n5XjaSb2u171pyYT8Vbl/YdA3fXn7WExcuribQpCB3","X-Received":["by 2002:a05:6102:440e:b0:42e:154b:3ca7 with SMTP id\n\tdf14-20020a056102440e00b0042e154b3ca7mr1146131vsb.3.1681385853349; \n\tThu, 13 Apr 2023 04:37:33 -0700 (PDT)","by 2002:a05:6102:440e:b0:42e:154b:3ca7 with SMTP id\n\tdf14-20020a056102440e00b0042e154b3ca7mr1146120vsb.3.1681385853027;\n\tThu, 13 Apr 2023 04:37:33 -0700 (PDT)"],"X-Google-Smtp-Source":"AKy350bcBu6f/YM5SM4ELmlTcJNB8DiuWW36+UNK1tOvcisxOOewV8SUFYyB+luV16k1/w4i+Z5gVkxSGtmXijv2FB8=","MIME-Version":"1.0","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>\n\t<168138439955.3536995.11061677505792244340@Monstersaurus>\n\t<CAOgh=FwBOAhACehrzM+TL0PcGz-rGgL5tOq5Opdz9c1vhs1+jw@mail.gmail.com>","In-Reply-To":"<CAOgh=FwBOAhACehrzM+TL0PcGz-rGgL5tOq5Opdz9c1vhs1+jw@mail.gmail.com>","Date":"Thu, 13 Apr 2023 12:37:16 +0100","Message-ID":"<CAOgh=FyDUAOefv=BMmMbWtQbtBHZ6j7voU3GU32XmhnE9JPa+Q@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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":"Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Eric Curtin <ecurtin@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org, Khem Raj <raj.khem@gmail.com>,\n\twtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26882,"web_url":"https://patchwork.libcamera.org/comment/26882/","msgid":"<168138982771.3536995.8200814990132244401@Monstersaurus>","date":"2023-04-13T12:43:47","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2023-04-13 12:37:10)\n> On Thu, Apr 13, 2023 at 12:13:19PM +0100, Kieran Bingham wrote:\n> > Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> > > On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > > > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                             ^~~~\n> > > > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                                                                 ^\n> > > > > > cc1plus: all warnings being treated as errors\n> > > > > >\n> > > > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > > >\n> > > > > I'm still hoping that holding off a little on this will ensure it's\n> > > > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > > > already add:\n> > > > >\n> > > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > > >\n> > > > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > > > getting to the point that we'll simply have to merge this. I guess it\n> > > > > depends on when gcc-13 is actually released?\n> > > > \n> > > > In a months time. It perhaps is not going to be fixed by atleast the\n> > > > first 13.x release. Maybe subsequent point releases\n> > > > might have it\n> > > \n> > > It looks like this won't be fixed in gcc :-(\n> > > \n> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> > > \n> > > Their recommendation is to use a pragma to disable the warning:\n> > > \n> > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > index b32aad247b8b..5fb075261a18 100644\n> > > --- a/src/apps/cam/file_sink.cpp\n> > > +++ b/src/apps/cam/file_sink.cpp\n> > > @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > >         }\n> > > \n> > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > +#pragma GCC diagnostic push\n> > > +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n> > >                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > +#pragma GCC diagnostic pop\n> > > \n> > >                 Span<uint8_t> data = image->data(i);\n> > >                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > \n> > I think I'd prefer to apply the patch suggested here than add a pragma!\n> > \n> > Laurent, any objection? Lets get this resolved quickly now we know it's\n> > not going to be fixed in gcc.\n> \n> There are pros and cons (as always). The pragma is self-documenting,\n> which I like. Even with the comment below, future refactoring may\n> reintroduce the problem.\n\nExcept at that point, GCC-13 will be included in the build-matrix, as a\nsupported compiler... so it's not going to 'sneak in'.\n\n--\nKieran\n\n\n> \n> > > > > > ---\n> > > > > > Changes in v3:\n> > > > > >\n> > > > > > - Added comment explaining change made because of false negative in gcc\n> > > > > >\n> > > > > > Changes in v2:\n> > > > > >\n> > > > > > - Added const\n> > > > > > - Made patch mergeable by accounting for new directory structure\n> > > > > > ---\n> > > > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > > > >\n> > > > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > > > index b32aad24..01846cdb 100644\n> > > > > > --- a/src/apps/cam/file_sink.cpp\n> > > > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > > > >         }\n> > > > > >\n> > > > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > > -\n> > > > > > +               /*\n> > > > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > > > +                * causing false negative (gcc 13):\n> > > > > > +                * \"possibly dangling reference to a temporary\"\n> > > > > > +                */\n> > > > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > > > >                 Span<uint8_t> data = image->data(i);\n> > > > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > > > >\n> > > > > > -               if (meta.bytesused > data.size())\n> > > > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > > > +               if (bytesused > data.size())\n> > > > > > +                       std::cerr << \"payload size \" << bytesused\n> > > > > >                                   << \" larger than plane size \" << data.size()\n> > > > > >                                   << std::endl;\n> > > > > >\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 011AEC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 12:43:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3207E627B8;\n\tThu, 13 Apr 2023 14:43:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F38A561EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 14:43:50 +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 08CCDD20;\n\tThu, 13 Apr 2023 14:43:48 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681389832;\n\tbh=oGOOCc3vOHLgJY07og1AsdZklU72xVVKsDqbLsW3crI=;\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:Cc:\n\tFrom;\n\tb=hJHLDdy4tfUXuUK1/zf0GWqsOp1ZLdgB99Xthy+GmNDEqrZex+tNZNFylAbVICAyg\n\tmC3WhsrJxQ+zCy0xvXWy19cuY9Y8CQPtuHbvZs4GcIUdd/0GTy7PWwBC5Wnyxqj5vs\n\tP5Y3nSm248Gq7Jp0UzfyRxjtjyvCd7bES/neHa2ZfG1qnjz0pnWMgkYfGDQQXvjqk5\n\tdimm3dvOIbFX0yzN/pJTtazk81LWouQpaUGjfOUmHnj/+ETk7fVDo0uB5DIZ9sw+M2\n\tY/ooa9gm+GsWhOj/2S7PkX32p3OD3c3lxGnTPvOnKmuuE3NsT0A0DASyvqxhWYR4hC\n\t0vu3pPqS/l00Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681389828;\n\tbh=oGOOCc3vOHLgJY07og1AsdZklU72xVVKsDqbLsW3crI=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=YqaN+qNe2PG2EWBMi9rAQ0yg4cUDS8CO+fMDs0BVq9FE3SVAI9ehGkBP5OF16MF7j\n\t0p+ix1i6l+5RKfML17nMEA1R1WuWtl/5EoIrX3/ieJubgYlvQrBD10yWltqoGzocPj\n\tIcwuirdY5jXDK9zR/bfAjpkoANcmTJGoYLoj/x2A="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YqaN+qNe\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20230413113710.GA23208@pendragon.ideasonboard.com>","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>\n\t<168138439955.3536995.11061677505792244340@Monstersaurus>\n\t<20230413113710.GA23208@pendragon.ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Thu, 13 Apr 2023 13:43:47 +0100","Message-ID":"<168138982771.3536995.8200814990132244401@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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>","Cc":"libcamera-devel@lists.libcamera.org, Khem Raj <raj.khem@gmail.com>,\n\twtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26883,"web_url":"https://patchwork.libcamera.org/comment/26883/","msgid":"<CAMKF1sow1vcPv207N0UACJwDF+-LrYXnkQC+K9WZ2FTLhvsJCA@mail.gmail.com>","date":"2023-04-13T13:14:01","subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","submitter":{"id":62,"url":"https://patchwork.libcamera.org/api/people/62/","name":"Khem Raj","email":"raj.khem@gmail.com"},"content":"On Thu, Apr 13, 2023 at 4:37 AM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> On Thu, Apr 13, 2023 at 12:13:19PM +0100, Kieran Bingham wrote:\n> > Quoting Laurent Pinchart (2023-04-13 12:07:02)\n> > > On Tue, Mar 28, 2023 at 10:26:58AM -0700, Khem Raj wrote:\n> > > > On Tue, Mar 28, 2023 at 10:13 AM Kieran Bingham wrote:\n> > > > > Quoting Eric Curtin (2023-02-20 04:55:24)\n> > > > > > ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference]\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                             ^~~~\n> > > > > > ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span<const libcamera::FrameMetadata::Plane>::operator[](i)'\n> > > > > >    92 |                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > >       |                                                                                 ^\n> > > > > > cc1plus: all warnings being treated as errors\n> > > > > >\n> > > > > > Co-developed-by: Khem Raj <raj.khem@gmail.com>\n> > > > > > Signed-off-by: Eric Curtin <ecurtin@redhat.com>\n> > > > >\n> > > > > I'm still hoping that holding off a little on this will ensure it's\n> > > > > fixed in the compiler before GCC-13 is released - but I think I can also\n> > > > > already add:\n> > > > >\n> > > > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > > >\n> > > > > And given a fix was added to gcc-13, but it didn't fix /this/ we may be\n> > > > > getting to the point that we'll simply have to merge this. I guess it\n> > > > > depends on when gcc-13 is actually released?\n> > > >\n> > > > In a months time. It perhaps is not going to be fixed by atleast the\n> > > > first 13.x release. Maybe subsequent point releases\n> > > > might have it\n> > >\n> > > It looks like this won't be fixed in gcc :-(\n> > >\n> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165#c9\n> > >\n> > > Their recommendation is to use a pragma to disable the warning:\n> > >\n> > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > index b32aad247b8b..5fb075261a18 100644\n> > > --- a/src/apps/cam/file_sink.cpp\n> > > +++ b/src/apps/cam/file_sink.cpp\n> > > @@ -114,7 +114,10 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > >         }\n> > >\n> > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > +#pragma GCC diagnostic push\n> > > +#pragma GCC diagnostic ignored \"-Wdangling-reference\"\n> > >                 const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > +#pragma GCC diagnostic pop\n> > >\n> > >                 Span<uint8_t> data = image->data(i);\n> > >                 unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> >\n> > I think I'd prefer to apply the patch suggested here than add a pragma!\n> >\n> > Laurent, any objection? Lets get this resolved quickly now we know it's\n> > not going to be fixed in gcc.\n>\n> There are pros and cons (as always). The pragma is self-documenting,\n> which I like. Even with the comment below, future refactoring may\n> reintroduce the problem.\n\nI would prefer to patch it and help compiler. This also makes it\nportable across multiple versions of gcc\nand other compilers even if it means some restrictions on how it is written.\nfuture refactoring will hopefully use gcc in some capacity and you\nwill run into problem early\n>\n> > > > > > ---\n> > > > > > Changes in v3:\n> > > > > >\n> > > > > > - Added comment explaining change made because of false negative in gcc\n> > > > > >\n> > > > > > Changes in v2:\n> > > > > >\n> > > > > > - Added const\n> > > > > > - Made patch mergeable by accounting for new directory structure\n> > > > > > ---\n> > > > > >  src/apps/cam/file_sink.cpp | 14 +++++++++-----\n> > > > > >  1 file changed, 9 insertions(+), 5 deletions(-)\n> > > > > >\n> > > > > > diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp\n> > > > > > index b32aad24..01846cdb 100644\n> > > > > > --- a/src/apps/cam/file_sink.cpp\n> > > > > > +++ b/src/apps/cam/file_sink.cpp\n> > > > > > @@ -114,13 +114,17 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer,\n> > > > > >         }\n> > > > > >\n> > > > > >         for (unsigned int i = 0; i < buffer->planes().size(); ++i) {\n> > > > > > -               const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];\n> > > > > > -\n> > > > > > +               /*\n> > > > > > +                * formerly \"const FrameMetadata::Plane &\"\n> > > > > > +                * causing false negative (gcc 13):\n> > > > > > +                * \"possibly dangling reference to a temporary\"\n> > > > > > +                */\n> > > > > > +               const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;\n> > > > > >                 Span<uint8_t> data = image->data(i);\n> > > > > > -               unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());\n> > > > > > +               const unsigned int length = std::min<unsigned int>(bytesused, data.size());\n> > > > > >\n> > > > > > -               if (meta.bytesused > data.size())\n> > > > > > -                       std::cerr << \"payload size \" << meta.bytesused\n> > > > > > +               if (bytesused > data.size())\n> > > > > > +                       std::cerr << \"payload size \" << bytesused\n> > > > > >                                   << \" larger than plane size \" << data.size()\n> > > > > >                                   << std::endl;\n> > > > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 BB4B3BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Apr 2023 13:14:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07DE1627B1;\n\tThu, 13 Apr 2023 15:14:31 +0200 (CEST)","from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com\n\t[IPv6:2001:4860:4864:20::2a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 898BD61EC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 15:14:29 +0200 (CEST)","by mail-oa1-x2a.google.com with SMTP id\n\t586e51a60fabf-187916b6543so2077534fac.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Apr 2023 06:14:29 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681391671;\n\tbh=gQ8D0Gk6hEyVYLcHzf1thpmUKtFVlPoetUZZOXbHHCw=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=KDHIcfhjdMKgPoXVw/zRSLvRGfVnd/IdQ8Ccl+waIq6igh8kZSuD8lkuHEMKAXNXa\n\tnV3fRROLqEG4F7QUv9mTjV5CHpG3xr4Won53poVBkC1LJAWMv4VhlkO4bpOd4Eq8jA\n\tE8KFyBhNvO9BMvQr+6NY45kQb8cycVCF4NtU186cTyub/MQVS/tJcIrgtGflIWvKBm\n\tdFbsaD1YRSagLATfcB5NqeuZ7bROv8qOhC1pOLDKWqSeOuD1LTtbi6rzmj0Kk5hM6a\n\tj1W5CMObM8QNntNVjlLC8ES+W1b0uZBZEK2xtVP4c4brRgJS4o7ciExDvSRS43BGV7\n\tRPnu5YqF0M1mA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20221208; t=1681391668; x=1683983668;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=6zjkSC25yp0WtJeWcmep2azSCRMjEN0RPEwcvAn0ZbE=;\n\tb=HXvCXEj9cTjkhVIgPQp1c9wTFmMxnpzWL9NCFPvxGEMMpQyVcHEcjwaoAiqmqCp/M8\n\tBh13X8L+R2j+9yOCuyY7zi8i/Yhj23Fc3gY5aUjo77LDC/6beRHDSrMkxLuY4luOzqKr\n\t7rcEpjwirLC3fRS0O/O66AZK53ISsm6+5uQfTPf4EenthPgYtsnAR+pbBZgBo439occo\n\tji4I4/nRT9EseIp11WEOBZaeURdOWFxt94hMzFhUOgrS7y+BJZpueYDwlEK+23fYixAb\n\tq1ISbG+/PdXEkCHtsfmVSYGpo40ZNX25SdCAhCY/iYih4NbRaWnUkKl1A/ejNVfnVTP+\n\t912A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"HXvCXEj9\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1681391668; x=1683983668;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=6zjkSC25yp0WtJeWcmep2azSCRMjEN0RPEwcvAn0ZbE=;\n\tb=GwSbiCY4LKan7o7JDbCjMXzKW0hfJ8VN/i5Pn+BJR9NRnDsIevo15uccdxl1Mq9VaM\n\tET1UKaOrBRJLvjCB3dDtpWOoW14FJT8oMxp45Vooce14HMeb30qfOQsnF+2nNsfao6h5\n\tRMIgU/S1UJXyueUhu6sM8NLS3IZ2sMJNKXemcBs80DaYsuYie11OFtFk0JyttpInGQvw\n\tcfJQ45Th5DZm6b+oDR29X4NbNUH2A7jiyDKFph2Hn/SvqUe9HK2EehV3idEokB92LVas\n\to96c0+ZV4UXUQDRVBQbCJLVRxlMl/3eUI8MHSwoCFltgavHtzxLtQzlgss4UaizAqKrv\n\tVQpg==","X-Gm-Message-State":"AAQBX9f7HdKIPbk5Tpt8jto1A6q05EroEdZSdO4hf7Vvygs8ioqfNM5v\n\tISvPl7okjcwSWt9zU7YJi81HrxdM2YsAQmgMJjw=","X-Google-Smtp-Source":"AKy350ZoyU1/hyTLj/6uCpVnLZkjot44F7FqXvXNMf7o83ZXnypJ+uqrlF8JGKQUDCdVBQ/VVblB78SAoizhBK6wu0g=","X-Received":"by 2002:a05:6871:7a3:b0:187:7f01:7e75 with SMTP id\n\to35-20020a05687107a300b001877f017e75mr1044768oap.4.1681391668046;\n\tThu, 13 Apr 2023 06:14:28 -0700 (PDT)","MIME-Version":"1.0","References":"<20230220045523.3884-1-ecurtin@redhat.com>\n\t<168002357384.765114.2730090820205171786@Monstersaurus>\n\t<CAMKF1sp-xbsmob0rzmsjoGVqP504HCB0qrBtTc=VPAx8A8971g@mail.gmail.com>\n\t<20230413110702.GA11253@pendragon.ideasonboard.com>\n\t<168138439955.3536995.11061677505792244340@Monstersaurus>\n\t<20230413113710.GA23208@pendragon.ideasonboard.com>","In-Reply-To":"<20230413113710.GA23208@pendragon.ideasonboard.com>","Date":"Thu, 13 Apr 2023 06:14:01 -0700","Message-ID":"<CAMKF1sow1vcPv207N0UACJwDF+-LrYXnkQC+K9WZ2FTLhvsJCA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v3] cam: file_sink: Fixes following\n\terrors with gcc-13","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":"Khem Raj via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Khem Raj <raj.khem@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org, wtaymans@redhat.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]