https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110149
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It looks like I forgot to actually format using 'P' though, I only parsed it
from the format string.
This would fix that, and disable the P2519 changes for -std=c++20 and
-std=c++23:
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -2081,19 +2081,29 @@ namespace __format
if (__finished())
return __first;
+#if __cplusplus > 202302L || ! defined __STRICT_ANSI__
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// P2519R3 Formatting pointers
__first = __spec._M_parse_zero_fill(__first, __last);
if (__finished())
return __first;
+#endif
__first = __spec._M_parse_width(__first, __last, __pc);
- if (__first != __last && (*__first == 'p' || *__first == 'P'))
+ if (__first != __last)
{
- if (*__first == 'P')
+ if (*__first == 'p')
+ ++__first;
+#if __cplusplus > 202302L || ! defined __STRICT_ANSI__
+ else if (*__first == 'P'))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // P2519R3 Formatting pointers
__spec._M_type = __format::_Pres_P;
- ++__first;
+ ++__first;
+ }
+#endif
}
if (__finished())
@@ -2113,6 +2123,18 @@ namespace __format
const int __n = __ptr - __buf;
__buf[0] = '0';
__buf[1] = 'x';
+#if __cplusplus > 202302L || ! defined __STRICT_ANSI__
+ if (_M_spec._M_type == _Pres_)
+ {
+ __buf[1] = 'X';
+ for (auto __p = __buf + 2; __p != __res.ptr; ++__p)
+#if __has_builtin(__builtin_toupper)
+ *__p = __builtin_toupper(*__p);
+#else
+ *__p = std::toupper(*__p);
+#endif
+ }
+#endif
basic_string_view<_CharT> __str;
if constexpr (is_same_v<_CharT, char>)