From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1FC3383FBBA; Mon, 12 Sep 2022 16:18:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1FC3383FBBA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662999480; bh=S+hEOTiQ+5lCjmRf/O0jZF6zMvQ1SZ/lspcGOQ7Ps9w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F2fKnkz4a8mFdEEyiMj7ebsVGhfookFGjziG2hbyNKJwQo6TKyF5VNmWmEec8iU0S i5z6BOPhzbVhHm9c0hIeG8BTAG15uhvt/y1M59P36qhhsjldKl4S8He9YmZKvADXXx pP8T6SydA2Sf9NJuqQo59VVwD0SZy8lsT2e5rYnQ= From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106868] [12/13 Regression] Bogus -Wdangling-pointer warning with -O1 Date: Mon, 12 Sep 2022 16:18:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D106868 --- Comment #2 from Martin Sebor --- (In reply to Richard Biener from comment #1) > Confirmed. >=20 > [local count: 1073741824]: > alloc (&q); > q.0_1 =3D q; > *p_4(D) =3D q.0_1; > q =3D{v} {CLOBBER(eol)}; > a_8 =3D __builtin_memcpy (q.0_1, "", 1); > *a_8 =3D 0; > return; ... > we somehow confuse q.0_1 =3D q; as assigning the address of the object 'q= '. The reason for the false positive is plain to see in the IL: the memcpy cal= l is passed a copy of the clobbered q. It then returns another copy of the same= q which is then used to dereference whatever the pointer points to. The warn= ing is due to the (known) mismatch between how the optimizers and the warning interpret clobbers: (IIUC) the optimizers treat it as the value of the assi= gned variable alone becoming indeterminate, while the warning as all copies of it becoming so.=