libstdc++: Reserve _Pres_type for prefixed hexadecimal floating presentation
Reserves internal type values for future prefixed hexadecimal output in floating-point formatting, avoiding link-time issues.
To support the future addition of prefixed hexadecimal floating-point output (e.g., 0x1.23p+4), this patch reserves new _Pres_type values within libstdc++. While no new format specifier is introduced yet, reserving these values prevents linking errors between older and newer versions of the library and prepares for a potential C++ standard defect report. Existing internal uses of _Pres_p and _Pres_P for pointers were adjusted to use hexadecimal integer presentation values instead.
In Details
The libstdc++-v3/include/std/format header is being updated to accommodate prefixed hexadecimal floating-point representations, as suggested by LWG4515. This change reserves new _Pres_type values (_Pres_p, _Pres_P) for this purpose. It also adjusts __formatter_fp to use these new values and modifies __formatter_ptr to use _Pres_x/_Pres_X and _M_alt for its existing functionality, preventing ABI conflicts and enabling future standard-driven changes.
- LWG4515
- A specific issue or proposal from the C++ Library Working Group concerning the hexadecimal format specifiers 'a' and 'A' for floating-point numbers, advocating for the inclusion of the '0x' or '0X' prefix.
- _Pres_type
- An internal enumeration or type used by
std::formatin libstdc++ to represent the desired presentation format of a value (e.g., decimal, hexadecimal, scientific). - hexadecimal floating presentation
- A way to represent floating-point numbers using base-16, similar to scientific notation but with hexadecimal digits and a power-of-16 exponent (e.g., 0x1.fp+10).
- TU (Translation Unit)
- A source file after it has been preprocessed and compiled into an intermediate object file. Linking multiple TUs forms the final executable or library.
- DR (Defect Report)
- A mechanism within the C++ standards process for formally reporting issues or ambiguities in the standard language or library, which may lead to official clarifications or amendments.