From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D9AB23882066; Thu, 13 Jun 2024 16:09:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9AB23882066 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718294971; bh=UJctMGr9E0OkiJG9+ciIroVxnByX10syvYHEJ4PHDao=; h=From:To:Subject:Date:In-Reply-To:References:From; b=w17sdyIxE9vkuQeD32bgpxpPHLRkjYGtO0Qceqh0f6Hdft9Xw22CuQCJBhwMC0ymG LvFNHw8ADy26Krl+XGcWKS9ZyGQnqFWQjJ0eJs5KH9NLiZrAx8HoN/BzD1xbr+QZY0 j9/DH+ruQsMg9NSMgxg4Q7X9qlqEitDRRA1rxZm0= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/28103] std::operator<<(ostream&, string) sets badbit instead of failbit on failure Date: Thu, 13 Jun 2024 16:09:30 +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: 4.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status 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=3D28103 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Status|SUSPENDED |NEW --- Comment #3 from Jonathan Wakely --- MSVC sets badbit, just like we do: https://github.com/microsoft/STL/blob/e36ee6c2b9bc6f5b1f70776c18cf5d3a93a69= 798/stl/inc/__msvc_string_view.hpp#L483 (and other lines in that function). Libc++ sets both failbit and badbit: https://github.com/llvm/llvm-project/blob/dc8e078a59a65a8e2b4dd13954bfa497b= 30ef0e8/libcxx/include/__ostream/basic_ostream.h#L514 The requirement to set failbit came from https://cplusplus.github.io/LWG/issue211 and certainly seems consistent with other input operations, which set failbit not badbit. N.B. https://wg21.link/p1264r2 cleaned up the wording for input operations, making it clear that badbit should only be set by the library after an input operation throws an exception. The libc++ behaviour seems like a reasonable compromise between what the standard says and what existing user code might be expecting (based on the behaviour of both MSVC and libstdc++). I'm unsuspending this to reopen it. I think we should *at least* set failbi= t. I'm ambivalent whether we continue to set badbit as well.=