Skip to content
Snippets Groups Projects
  • Jonathan Wakely's avatar
    260a22de
    libstdc++: Replace padding bits with bit-fields in __format::_Spec · 260a22de
    Jonathan Wakely authored
    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 flag to optimize the conversions between
    locale encodings and UTF-8.
    
    Adding the 16-bit _M_reserved2 bit-field results in an increased size
    for targets that use 1- or 2-byte alignment for all integral types, e.g.
    cris-elf or m68k.  Placing that member before the _M_width member
    adjusts the layout for all targets, but keeps all the bit-fields
    together. We can't make that change once C++20 support is ABI stable and
    non-experimental, so do it now before GCC 14 is released. The _M_fill
    data member already change from char to char32_t in
    r14-6991-g37a4c5c23a270c so _Spec is already incompatible with gcc-13
    anyway.
    
    libstdc++-v3/ChangeLog:
    
    	* include/std/format (__format::_Spec::_M_reserved): Define new
    	bit-field members to reserve padding bits for future extensions.
    260a22de
    History
    libstdc++: Replace padding bits with bit-fields in __format::_Spec
    Jonathan Wakely authored
    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 flag to optimize the conversions between
    locale encodings and UTF-8.
    
    Adding the 16-bit _M_reserved2 bit-field results in an increased size
    for targets that use 1- or 2-byte alignment for all integral types, e.g.
    cris-elf or m68k.  Placing that member before the _M_width member
    adjusts the layout for all targets, but keeps all the bit-fields
    together. We can't make that change once C++20 support is ABI stable and
    non-experimental, so do it now before GCC 14 is released. The _M_fill
    data member already change from char to char32_t in
    r14-6991-g37a4c5c23a270c so _Spec is already incompatible with gcc-13
    anyway.
    
    libstdc++-v3/ChangeLog:
    
    	* include/std/format (__format::_Spec::_M_reserved): Define new
    	bit-field members to reserve padding bits for future extensions.