[Bug c++/62160] std::uppercase does not work for std::hex output

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Sat Aug 16 14:47:00 GMT 2014


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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The observed behaviour looks correct to me. The effects of std::uppercase are
defined to set the basefeld to hex and this again corresponds to the stdio
equivalent of %X (see Table 85 — Integer conversions). The fprintf format
specification does specify that any of the x or X specifiers is relevant only
for integer types, there is no indication that pointer output according to the
%p (This is also what the C++ refers to) is affected by %x or %X. Keep in mind,
that the specification of void* output format does not require any specific
format. The specification only says:

"The argument shall be a pointer to void. The value of the pointer is
converted to a sequence of printing characters, in an implementation-defined
manner."

So, if you want to have more control over the IO of pointers, you should cast
the to an integer value (correctly done via std::[u]intptr_t), and output the
corresponding integer value.


More information about the Gcc-bugs mailing list