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

            Bug ID: 62160
           Summary: std::uppercase does not work for std::hex output
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jj at chaosbits dot net

Created attachment 33339
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33339&action=edit
pre-processed version of test.cc

Using std::uppercase should cause the use of uppercase characters in
hexadecimal integer output, but it does not seem to do so when that integer is
a pointer:

[jj@jj ~]$ g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[jj@jj ~]$ cat test.cc 
#include <iostream>
int main() {
    int* p = reinterpret_cast<int*>(42);
    int i = 42;
    std::cout << std::hex << std::uppercase << p << std::endl;
    std::cout << std::hex << std::uppercase << i << std::endl;
}
[jj@jj ~]$ g++ -std=c++11 test.cc 
[jj@jj ~]$ ./a.out 
0x2a
2A

As can be seen above, the output is clearly not uppercase in the pointer case
(although as far as I know; pointers are integers).

This looks like a bug to me, but maybe I'm just doing something exceptionally
stupid...

Reply via email to