From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A2A833858D33; Fri, 31 Mar 2023 11:17:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2A833858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680261446; bh=5dZ5RiQ4htkqUrFMxWWmvQGpRcKC0H50is4VMv5stqY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p1kam7tPWb1O5qU0vhL0mAq1jP2lp4Shb4GufxvqeFpXrGIuQLF/xWKKb4a4dImyN UfiuKPzf6Niaqp4T3yR2pHyZvf/i4M3PFaGvvfNjW6C4r3KGV6ROLhXkYnyQzjwDnZ 48H4FcOCArQNyHvBFzX0U2Iwfgckt9id6mxgFQE4= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109339] [12/13 Regression] stop_token compiled with -Og yields maybe-uninitialized Date: Fri, 31 Mar 2023 11:17:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ 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: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D109339 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #6 from Richard Biener --- OK, I suppose I was misled by trying to trace how the construction works. = The first half of my comment#2 still stands - we diagnose ss =3D{v} {CLOBBER}; std::stop_token::_Stop_state_ref::_Stop_state_ref (&ss._M_state, &ss); by (maybe broken) design, the &ss argument is a const reference which we decide implies read. In this case we could even use modref to see the parameter is unused - but the call happens through an alias and in the -Og pipeline we do not run late modref. The called body is void std::stop_token::_Stop_state_ref::_Stop_state_ref (struct _Stop_state_= ref * const this, const struct stop_source & D.79270) { void * _5; [local count: 1073741824]: _5 =3D operator new (24); MEM[(struct _Stop_state_t *)_5]._M_owners.D.16955._M_i =3D 0; MEM[(struct _Stop_state_t *)_5]._M_value.D.16955._M_i =3D 0; MEM[(struct _Stop_state_t *)_5]._M_head =3D 0B; MEM[(struct _Stop_state_t *)_5]._M_requester._M_thread =3D 0; MEM[(struct __atomic_base *)_5]._M_i =3D 1; MEM[(struct __atomic_base *)_5 + 4B]._M_i =3D 4; MEM[(struct id *)_5 + 16B]._M_thread =3D 0; this_2(D)->_M_ptr =3D _5; return; } but since this function can be interposed even modref doesn't help (when scheduled and enabled) since it throws away this knowledge :/ Maybe we need some optimistic mode for diagnostic code (or add EAF_LIKELY_UNUSED). But as said (late) modref isn't in the -Og pipeline and it's only enabled with -O2+ anyway. The other possible heuristic adjustment would be noticing &ss is also passed as first non-const reference argument.=