From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4B01D38555A1; Tue, 28 Mar 2023 20:14:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B01D38555A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680034461; bh=02elSpaLg0jcRiW72pIoumJd8aiCGX6KaFRHnfo1jOA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N45H79B1uo+yQm0vgid8GG3YiBXhHvt4PixmgIBzm6Jvt5+VxmJkR5LL8SJtElSKb Em8Fua7clw8c7Qj/Ndkkhub0cjRoiuXpnEk4Y72PPoYHKqxEvgmrRGYzpX6w+xHTPa 5acMD3DrkIG5XsL5NJ49fGes8E0cONPLVhgm/2aw= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109299] [12/13 Regression] wrong warning on std::wstring with -O2 -std=c++20 -D_FORTIFY_SOURCE=2 Date: Tue, 28 Mar 2023 20:14:21 +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: cvs-commit 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=3D109299 --- Comment #10 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:bf78b43873b0b7e8f9a430df38749b8b61f9c9b8 commit r13-6915-gbf78b43873b0b7e8f9a430df38749b8b61f9c9b8 Author: Jonathan Wakely Date: Tue Mar 28 10:50:40 2023 +0100 libstdc++: Tell GCC what basic_string::_M_is_local() means [PR109299] This avoids a bogus warning about overflowing a buffer, because GCC can't tell that we don't copy into the buffer unless it fits. By adding a __builtin_unreachable() hint we inform the compiler about the invariant that the buffer is only used when it's big enough. This can also improve codegen, by eliminating dead code that GCC couldn't tell was unreachable. libstdc++-v3/ChangeLog: PR libstdc++/109299 * include/bits/basic_string.h (basic_string::_M_is_local()): Add hint for compiler that local strings fit in the local buffer.=