From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0BEB43858C66; Thu, 12 Jan 2023 10:10:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BEB43858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673518235; bh=2d+tkEGWZKoqfxyELaqZQUkdZ3FCGI/HYm5bu/2u0ys=; h=From:To:Subject:Date:In-Reply-To:References:From; b=h4BDT6bTodJZ1ljGeeFobuiR/tMvwZ7IF/6gshiIG96u3rGGLekdQ2rhNmUx+s+Tj g32DXCumx2qRBvpOWeKjbLzRMp20W/bJOEgCzeDIeBGxdOkVkaxtf6v/CZJhEpTej0 +iPvTFkdpgW2EsdYOxRKHTxheg06/4ANpBgpEwJY= 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 10:10: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 #5 from Jonathan Wakely --- (In reply to Richard Biener from comment #4) > Hmm, but then the program is bogus, no? And a diagnostic warranted. No. > At least if it is well-defined to have a nullptr =3D=3D pointer. It's well defined, but that doesn't mean the program is bogus. It just means you can't call that function with such a value. > So I'd be inclined to close as INVALID? No, I don't think so. It would only be invalid if you called f(nullptr) or similar. The code is basically doing something like: int f(const A* p, bool is_valid) { const A* q =3D is_valid ? p : nullptr; return *q; } Instead of complaining that q might be null, we can optimize that to return= *p. It might be nicer to optimize it to: if (!p) __builtin_trap(); return *p; but either way, we can't just declare the whole program to be invalid becau= se it's possible to call the function incorrectly.=