From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5DC533858C54; Wed, 5 Apr 2023 18:35:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DC533858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680719745; bh=VgDbjY5ZDizyJ+xvl2El0QRKMCHLnT5IuqYmZw7vrmQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XODFeiff8U+w6jkTpcPCYgUrb8AznY4qupcBG7VzGyxi+QIa/XdpI9zgTqPfY3bva rCzilKBNVgwUeJgSztrsJsxl9ZAkKwI7nqQ9fOW3j6GB2+RE/lOgzaDtOykUFKDJlZ aQAY8ad7DVpTRCc8MBFd1I6mzaHf6YXDeyB9+ka8= From: "f.heckenbach@fh-soft.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/88508] std::bad_cast in std::basic_ostringstream.oss.fill() Date: Wed, 05 Apr 2023 18:35:44 +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: 8.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.heckenbach@fh-soft.de X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D88508 Frank Heckenbach changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |f.heckenbach@fh-soft.de --- Comment #2 from Frank Heckenbach --- According to https://stackoverflow.com/questions/57406448/canot-read-char8-t-from-basic-= stringstreamchar8-t this seems to be the same issue, so I'm not filing a new bug, just adding a comment. Apparently this is no GCC bug, but according to the standard. IMHO this sho= ws how ridiculous the current UTF-8 support is. A common I/O manipulator (setw) fails with an inscrutable error (bad cast, what cast?) which is even suppre= ssed by default, unless enabled with o.exceptions, so by the default the stream = just mysteriously stops working. And all that because the library doesn't know w= hat the space character is in UTF-8. Just ranting, I know, but it's silly. % cat test.cpp #include #include #include int main () { std::basic_ostringstream o; o.exceptions (std::ifstream::badbit); o << std::setw (1) << u8""; } % g++ -std=3Dc++20 -Wall -Wextra -o test test.cpp=20=20 % ./test terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted=