From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D1E883857C55; Wed, 1 Feb 2023 18:14:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1E883857C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675275253; bh=d7tmo8kkodj61rh2dTtUaqUo5MHVfSPlUu30hI+0ByI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B1UOwzhVEJB5dEXpkRIkxDN5fKcGnl4wzQfu3LVv/PkbwkKZrsygUf65xstNLJjOb yWgrsy48xgujLys0MSaNuNgmpNb/UqWOnmAQrvTSpPO1lM/AI6bJ3rWuBx79eC1PXt AFWiTQwmI/BnkJz/pDbUBaYr7CUdgEb5TwdZOVZw= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108165] -Wdangling-reference false positive Date: Wed, 01 Feb 2023 18:14:12 +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: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D108165 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- (In reply to Marek Polacek from comment #5) > Sorry, I'm not sure if the false positive in comment 0 can be fixed. I > can't simply compare the type of the temporary argument and the return ty= pe, > because we may be returning a subobject of the temporary argument, which = is > still dangerous. Well, you could e.g. walk recursively all the TYPE_FIELDS of the type of the temporary and compare to the type the return type references. If the temporary has s= ome subobject of that type or if the temporary itself has that type, warn, otherwise not warn. There would still be false positives and false negatives, but those are wit= hout actually looking at the definition unavoidable.=