public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "f.heckenbach@fh-soft.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/88508] std::bad_cast in std::basic_ostringstream<char16_t>.oss.fill()
Date: Sat, 08 Apr 2023 00:32:34 +0000	[thread overview]
Message-ID: <bug-88508-4-4pF47hG13J@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-88508-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88508

--- Comment #4 from Frank Heckenbach <f.heckenbach@fh-soft.de> ---
(In reply to Jonathan Wakely from comment #3)

I don't think my description is "completely wrong". I'm basically saying the
same as you, in plain English.

char8_t was introduced as the preferred type for holding UTF-8 text, so this
clearly has to do with UTF-8. (And I say "text" intentionally -- single
characters are usually better represented as char32_t code points while
encodings such as UTF-8 are used for text.) Streams are the main tool for input
and output and formatting in the standard library, so a text type which does
not support input, output and formatting is indeed ridiculous.

And "imbue the stream with the relevant facets" is just techspeak for telling
the stream what the space character is (and possibly other things), like I
said.

Moreover, if streams don't support char8_t by default, they should clearly say
so (which should be easy these days with concepts, otherwise even with SFINAE)
instead of giving obscure errors about a bad cast where there is no cast.

Again, I'm not blaming gcc if the standard says so, so this discussion here is
probably a waste of time, but it might serve as a warning to other users, to
avoid falling into this trap like I did -- which is easy to fall into when u8""
literals are char8_t[] by default, and char8_t's stated purpose is to hold
UTF-8.

  parent reply	other threads:[~2023-04-08  0:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-88508-4@http.gcc.gnu.org/bugzilla/>
2022-10-17 23:50 ` redi at gcc dot gnu.org
2023-04-05 18:35 ` f.heckenbach@fh-soft.de
2023-04-06  9:15 ` redi at gcc dot gnu.org
2023-04-08  0:32 ` f.heckenbach@fh-soft.de [this message]
2023-04-09 14:42 ` redi at gcc dot gnu.org
2023-04-09 20:13 ` f.heckenbach@fh-soft.de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-88508-4-4pF47hG13J@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).