public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libstdc++: Replace padding bits with a bit-field in __format::_Spec
@ 2024-02-01 15:36 Jonathan Wakely
  2024-02-01 15:36 ` [PATCH 2/2] libstdc++: Handle encodings in localized chrono formatting [PR109162] Jonathan Wakely
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jonathan Wakely @ 2024-02-01 15:36 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Hans-Peter Nilsson

I plan to push this to trunk soon.

CC HP for visibility of the change affecting cris-elf. In practice it
shouldn't make any difference to any sensible code. It only affects
C++20 mode (and later), and only changes the size of std::formatter
objects which are typically only created by the library headers
themselves, and only on the stack (when using std::format and other new
C++20 APIs related to it).

-- >8 --

This ensures that the unused bits will be zero-initialized reliably, and
so can be used later by assigning them values in formatter
specializations. For example, formatters for std::chrono will need to
use an extra bit for a boolean to optimize the conversions between
locale encodings and UTF-8.

This will result in an ABI change for targets that use 1-byte alignment
for all integral types, e.g. cris-elf. We can't do that once C++20
support is non-experimental and ABI stable, so do it now before GCC 14
is released.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::_Spec::_M_reserved): Define a
	new bit-field member in place of padding bits.
---
 libstdc++-v3/include/std/format | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 0eca8b58bfa..6c958bc11a5 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -406,6 +406,7 @@ namespace __format
       _WidthPrec _M_width_kind : 2;
       _WidthPrec _M_prec_kind : 2;
       _Pres_type _M_type : 4;
+      unsigned long _M_reserved : 17;
       unsigned short _M_width;
       unsigned short _M_prec;
       char32_t _M_fill = ' ';
-- 
2.43.0


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

end of thread, other threads:[~2024-02-01 19:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 15:36 [PATCH 1/2] libstdc++: Replace padding bits with a bit-field in __format::_Spec Jonathan Wakely
2024-02-01 15:36 ` [PATCH 2/2] libstdc++: Handle encodings in localized chrono formatting [PR109162] Jonathan Wakely
2024-02-01 16:43   ` Arsen Arsenović
2024-02-01 16:16 ` [PATCH 1/2] libstdc++: Replace padding bits with a bit-field in __format::_Spec Hans-Peter Nilsson
2024-02-01 17:08   ` Hans-Peter Nilsson
2024-02-01 17:21     ` Jonathan Wakely
2024-02-01 16:33 ` Andreas Schwab
2024-02-01 17:22   ` Jonathan Wakely
2024-02-01 17:28     ` Jonathan Wakely
2024-02-01 19:24     ` Jonathan Wakely
2024-02-01 19:50       ` Hans-Peter Nilsson

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