From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 87989385803F; Fri, 10 Dec 2021 16:53:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87989385803F From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103534] [12 regression] Spurious -Wstringop-overflow warning with std::string concatencation Date: Fri, 10 Dec 2021 16:53:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: alias, diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Dec 2021 16:53:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103534 --- Comment #8 from Martin Sebor --- We discussed before (e.g., in PR 93971) the idea of annotating std::string = with some attribute telling the optimizer the internal pointer doesn't alias with anything except for the this->_M_local_buf or the result of operator new().= =20 Richi seemed open to it but was concerned about correctness. I'm experimenting with two things to improve the context of all these warni= ngs. One is to print the folded condition under which the warning triggers. Th= is would include the conditions involved in all the ranges used to make decisi= ons. I posted the result for this warning here (I'm not sure it's complete, it's just a POC): https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586524.html Another is to print the path through the code (the CFG actually) leading up= to the warning site, like the static analyzer does. This will show each GIMPLE_COND after optimization, so it won't correspond exactly to the origi= nal source. For libstdc++ code it will show libstdc++ internal conditions that= may not be of much use to users. I'll have to see how bad it is to decide if i= t's a viable approach.=