public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107532] New: [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1
@ 2022-11-05  5:48 slyfox at gcc dot gnu.org
  2022-11-05 10:58 ` [Bug c++/107532] " rguenth at gcc dot gnu.org
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: slyfox at gcc dot gnu.org @ 2022-11-05  5:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532

            Bug ID: 107532
           Summary: [13 Regression] -Werror=dangling-reference false
                    positives in libcamera-0.0.1
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
                CC: mpolacek at gcc dot gnu.org
  Target Milestone: ---

libcamera-0.0.1 and a few other projects (like cvise) fail to compile due to
-Werror on -Werror=dangling-reference.

I think those are false positives related to value-like types that pass
references through.

Extracted example from libcamera:

// $ cat a.cpp.cpp

struct Plane { unsigned int bytesused; };

// Passes a reference through. Does not change lifetime.
template <typename Inner>
struct Ref {
    const Inner & i_;
    Ref(const Inner & i) : i_(i) {}
    const Inner & inner() { return i_; }
};

struct FrameMetadata {
    Ref<const Plane> planes() const { return p_; }

    Plane p_;
};

void bar(const Plane & meta);
void foo(const FrameMetadata & fm)
{
    const Plane & meta = fm.planes().inner();
    bar(meta);
}

$ g++-13.0.0 -c -Wall -Werror=dangling-reference a.cpp
a.cpp: In function 'void foo(const FrameMetadata&)':
a.cpp:20:19: error: possibly dangling reference to a temporary
[-Werror=dangling-reference]
   20 |     const Plane & meta = fm.planes().inner();
      |                   ^~~~
a.cpp:20:43: note: the temporary was destroyed at the end of the full
expression '(& fm)->FrameMetadata::planes().Ref<const Plane>::inner()'
   20 |     const Plane & meta = fm.planes().inner();
      |                          ~~~~~~~~~~~~~~~~~^~
cc1plus: some warnings being treated as errors

This gcc version is this week's gcc-13 snapshot with
https://gcc.gnu.org/PR107488 applied on top.

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2023-06-12 16:27 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05  5:48 [Bug c++/107532] New: [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1 slyfox at gcc dot gnu.org
2022-11-05 10:58 ` [Bug c++/107532] " rguenth at gcc dot gnu.org
2022-11-11 20:27 ` mpolacek at gcc dot gnu.org
2022-11-21 10:20 ` marxin at gcc dot gnu.org
2022-12-23  8:28 ` marxin at gcc dot gnu.org
2023-01-13 12:39 ` rguenth at gcc dot gnu.org
2023-01-16 16:43 ` mpolacek at gcc dot gnu.org
2023-01-24 17:38 ` jakub at gcc dot gnu.org
2023-01-24 17:41 ` mpolacek at gcc dot gnu.org
2023-01-24 17:44 ` jakub at gcc dot gnu.org
2023-01-24 17:50 ` mpolacek at gcc dot gnu.org
2023-02-01 14:44 ` pobrn at protonmail dot com
2023-02-14 13:31 ` ecurtin at redhat dot com
2023-02-14 13:45 ` mpolacek at gcc dot gnu.org
2023-03-07 16:11 ` cvs-commit at gcc dot gnu.org
2023-03-07 16:11 ` mpolacek at gcc dot gnu.org
2023-03-08 11:00 ` marxin at gcc dot gnu.org
2023-03-09 11:47 ` marxin at gcc dot gnu.org
2023-03-10 16:46 ` mpolacek at gcc dot gnu.org
2023-03-10 16:52 ` redi at gcc dot gnu.org
2023-03-10 17:02 ` pobrn at protonmail dot com
2023-03-10 17:17 ` mpolacek at gcc dot gnu.org
2023-03-10 17:18 ` mpolacek at gcc dot gnu.org
2023-03-12 10:49 ` eike@sf-mail.de
2023-03-12 13:37 ` flast at flast dot jp
2023-03-13 15:21 ` cvs-commit at gcc dot gnu.org
2023-03-13 15:53 ` mpolacek at gcc dot gnu.org
2023-03-14 23:09 ` flast at flast dot jp
2023-03-16 15:51 ` mpolacek at gcc dot gnu.org
2023-03-16 16:24 ` mpolacek at gcc dot gnu.org
2023-03-23 13:32 ` cvs-commit at gcc dot gnu.org
2023-03-23 13:33 ` mpolacek at gcc dot gnu.org
2023-03-23 15:22 ` gcc-bugzilla at al42and dot me
2023-04-11 16:09 ` gnu.ojxq8 at dralias dot com
2023-04-12 19:46 ` gnu.ojxq8 at dralias dot com
2023-04-12 19:49 ` mpolacek at gcc dot gnu.org
2023-04-27 22:29 ` cuzdav at gmail dot com
2023-06-12  3:25 ` boris at kolpackov dot net
2023-06-12 16:27 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).