public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109162] New: C++23 improvements to std::format
@ 2023-03-16 21:08 redi at gcc dot gnu.org
  2023-03-16 21:08 ` [Bug libstdc++/109162] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-16 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109162
           Summary: C++23 improvements to std::format
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 106749
  Target Milestone: ---

https://wg21.link/P2372R3 formatting ranges
https://wg21.link/P2585R1 container formatting
https://wg21.link/P2419R2 localized chrono formatting (also p2372r3)
https://wg21.link/P2693R1 formatting thread::id and stacktrace


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106749
[Bug 106749] Implement C++23 library features

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
@ 2023-03-16 21:08 ` redi at gcc dot gnu.org
  2023-12-07 21:28 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-16 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Last reconfirmed|                            |2023-03-16
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
  2023-03-16 21:08 ` [Bug libstdc++/109162] " redi at gcc dot gnu.org
@ 2023-12-07 21:28 ` redi at gcc dot gnu.org
  2023-12-07 21:29 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-12-07 21:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> https://wg21.link/P2372R3 formatting ranges

Oops, that should be https://wg21.link/p2286r8

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
  2023-03-16 21:08 ` [Bug libstdc++/109162] " redi at gcc dot gnu.org
  2023-12-07 21:28 ` redi at gcc dot gnu.org
@ 2023-12-07 21:29 ` redi at gcc dot gnu.org
  2023-12-09 22:05 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-12-07 21:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> https://wg21.link/P2693R1 formatting thread::id and stacktrace

This has been implemented for gcc-14

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-12-07 21:29 ` redi at gcc dot gnu.org
@ 2023-12-09 22:05 ` redi at gcc dot gnu.org
  2023-12-16 23:34 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-12-09 22:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109162
Bug 109162 depends on bug 111826, which changed state.

Bug 111826 Summary: __cpp_lib_format should be 202110, not 202106
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111826

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-12-09 22:05 ` redi at gcc dot gnu.org
@ 2023-12-16 23:34 ` redi at gcc dot gnu.org
  2024-01-10 22:52 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2023-12-16 23:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> https://wg21.link/P2419R2 localized chrono formatting (also p2372r3)

I think this this requires using nl_langinfo_l(CODESET, loc) to find out if the
locale uses UTF-8, and then use iconv to convert to UTF-8 if it doesn't. But
I'm not sure how we do that for an arbitrary std::locale which doesn't have an
associated C locale, and we can't get its locale_t identifier anyway.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-12-16 23:34 ` redi at gcc dot gnu.org
@ 2024-01-10 22:52 ` redi at gcc dot gnu.org
  2024-01-10 22:53 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-10 22:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> (In reply to Jonathan Wakely from comment #0)
> > https://wg21.link/P2419R2 localized chrono formatting (also p2372r3)
> 
> I think this this requires using nl_langinfo_l(CODESET, loc) to find out if
> the locale uses UTF-8, and then use iconv to convert to UTF-8 if it doesn't.
> But I'm not sure how we do that for an arbitrary std::locale which doesn't
> have an associated C locale, and we can't get its locale_t identifier anyway.

I remain confused about how to implement this. We could use
newlocale(loc.name()) to try to open a C locale from the C++ locale's name, and
if that works use nl_langinfo_l to get the locale's encoding, then use iconv to
convert to UTF-8.

Libc++ doesn't implement this yet. {fmt} does ... but it seems broken. It uses
std::codecvt<char32_t, char, mbstate_t> to convert the locale's encoding to
UTF-32 and then converts that to UTF-8. But that's wrong. That codecvt
specialization converts between UTF-8 and UTF-32, it's locale-independent. So
the example in P2419 fails with a format_error exception when I run it:

#include <locale>
#include <print>
#include <chrono>
#include <iostream>
#include <fmt/format.h>
#include <fmt/chrono.h>

int main()
{
  std::locale::global(std::locale("ru_UA.koi8u"));
  std::string s = fmt::format("День недели: {:L}", std::chrono::Monday);
  std::cout << s << '\n';
}

terminate called after throwing an instance of 'fmt::v9::format_error'
  what():  failed to format time
Aborted (core dumped)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-01-10 22:52 ` redi at gcc dot gnu.org
@ 2024-01-10 22:53 ` redi at gcc dot gnu.org
  2024-01-11 11:47 ` redi at gcc dot gnu.org
  2024-01-17 16:51 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-10 22:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Since the set of locales that get this encoding conversion is impl-defined, we
*could* just say that for libstdc++ the set is empty. Done, feature implemented
:-P

That's cheating though.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-01-10 22:53 ` redi at gcc dot gnu.org
@ 2024-01-11 11:47 ` redi at gcc dot gnu.org
  2024-01-17 16:51 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-11 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |113318

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> I remain confused about how to implement this. We could use
> newlocale(loc.name()) to try to open a C locale from the C++ locale's name,
> and if that works use nl_langinfo_l to get the locale's encoding,

P1185 (PR 113318) provides a standard API for doing that. So it probably makes
sense to implement that part of P1185 before doing P2419.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113318
[Bug 113318] [C++23] Implement P1185R12, Naming text encodings to demystify
them

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libstdc++/109162] C++23 improvements to std::format
  2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-01-11 11:47 ` redi at gcc dot gnu.org
@ 2024-01-17 16:51 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-17 16:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109162
Bug 109162 depends on bug 113318, which changed state.

Bug 113318 Summary: [C++23] Implement P1185R12, Naming text encodings to demystify them
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113318

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-17 16:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 21:08 [Bug libstdc++/109162] New: C++23 improvements to std::format redi at gcc dot gnu.org
2023-03-16 21:08 ` [Bug libstdc++/109162] " redi at gcc dot gnu.org
2023-12-07 21:28 ` redi at gcc dot gnu.org
2023-12-07 21:29 ` redi at gcc dot gnu.org
2023-12-09 22:05 ` redi at gcc dot gnu.org
2023-12-16 23:34 ` redi at gcc dot gnu.org
2024-01-10 22:52 ` redi at gcc dot gnu.org
2024-01-10 22:53 ` redi at gcc dot gnu.org
2024-01-11 11:47 ` redi at gcc dot gnu.org
2024-01-17 16:51 ` redi at gcc dot gnu.org

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).