From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2FBF63858C66; Thu, 12 Jan 2023 09:57:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FBF63858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673517455; bh=bYHMogPYPc3lSgIyKzea9kHQHWt4vwPcwyJqn/QKVRE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i/LU+poteuii6mVagkPBdfZPsckvRSIIBPqiw5iOuTLKZXvTzk6+HWGeZASGtB7Ny cqVvvrofe6WIqFlFzPZ8lBGGQiDFCUnu058cnTMmXujUQN86XQ45ziRe0ubl1Pm7RF KkyAdp3QjwyFjVr/E8IXl5EYgeyyHGdemB+yb/DI= From: "redi 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 09:57:34 +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: redi 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 #3 from Jonathan Wakely --- (In reply to Romain Geissler from comment #0) > std::weak_ptr weakPointer(pointer); >=20 > [[maybe_unused]] const unsigned int aAttr =3D weakPointer.lock()->_at= tr; 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. Instead of complaining about it, I would expect GCC to treat that undefined condition as unreachable and optimize it away.=