From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4220A3858D35; Thu, 12 Jan 2023 10:00:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4220A3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673517606; bh=4lf26nSxqq0+zphhDernLiOzhqKhFlJTPPUI7+SXDtE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M1SPCGm8f9INugTM/dBZg1ESnACxXDSVNLGUrGQ3gLAUiUi8z04oyf93F3hH/l4Im nAkUgpAbIBM98IZORBpPjPgnO7VmZqay2VygM4SWxbUak/jDg91kZAXdDIgUCHqbe3 xHqmTvlIoZY3XPchrr3iZAzw4hhBiDQvDOJdnlN8= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108374] [12/13 Regression] unexpected -Wstringop-overflow when using std::atomic and std::shared_ptr Date: Thu, 12 Jan 2023 10:00:06 +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: rguenth 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=3D108374 --- Comment #4 from Richard Biener --- (In reply to Jonathan Wakely from comment #3) > (In reply to Romain Geissler from comment #0) > > std::weak_ptr weakPointer(pointer); > >=20 > > [[maybe_unused]] const unsigned int aAttr =3D weakPointer.lock()->_= attr; >=20 > If pointer =3D=3D nullptr then weakPointer.lock() is also null, and so > dereferencing it to access the attr member is undefined, and does indeed > perform an atomic load at address 0. >=20 > Instead of complaining about it, I would expect GCC to treat that undefin= ed > condition as unreachable and optimize it away. Hmm, but then the program is bogus, no? And a diagnostic warranted. At least if it is well-defined to have a nullptr =3D=3D pointer. So I'd be inclined to close as INVALID?=