From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0891D3858D1E; Tue, 24 Jan 2023 17:41:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0891D3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674582089; bh=Cj7xwV40JpI+JsVi2mLK9urR7UEHYkOtWwP0Gyr4zBQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aYg+RlvRBOit2nR+G3+I8zxx3s2W9WtB7QM84gBPcC75eKbKYjlZ35ayKBfMc/3Tu pXzJ7PJnqfo7/jsJy9ZD567I4tSEGPdM9qSY9LQkDYFRD0nnfOnjRJp0hhT5xjXYH7 IrWMJeFO8aw9F9cuALH85LPT+IdsAeRaa3/CdknM= From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107532] [13 Regression] -Werror=dangling-reference false positives in libcamera-0.0.1 Date: Tue, 24 Jan 2023 17:41:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107532 --- Comment #5 from Marek Polacek --- (In reply to Jakub Jelinek from comment #4) > Yeah, without analyzing what the function call (constructor in this case) > actually does > hard to say whether the warning is ok or not. > Maybe some heuristics based on the types? Yes, I'm about to post another patch in response to . > The reference in question is const Plane &, so see if the reference could > bind to some member of the class that is destructed at the end of the > statement (Ref) or the class itself? > Even with that there can be false positives and false negatives, > e.g. the to be destructed temporary could contain a pointer to a heap > allocated Plane and return a reference to that and then deallocate it in = the > destructor (it would then be a dangling reference that with the change > wouldn't be warned about), or > on the other side, e.g. if the possibly dangling reference is const Whate= ver > & > and the temporary is Whatever, it might be likely that the reference is to > the > temporary, but it could be just a value of some member of it that would > happen to have that type. It's tricky. I've seen unfixable problems with range-based for loops, for instance.=