This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/23757] iostreams hex formatting for signed integers treats than as unsigned
- From: "x at xman dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Sep 2005 18:40:54 -0000
- Subject: [Bug libstdc++/23757] iostreams hex formatting for signed integers treats than as unsigned
- References: <20050906234941.23757.x@xman.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From x at xman dot org 2005-09-07 18:40 -------
The behavior we are mimicing isn't printf()'s behavior. printf() doesn't print
out hexadecimal signed integers as though they were unsigned integers. Intead,
C's type coercion allows the signed integers to be interpreted as unsigned
integers, and printf() then prints out the unsigned integers. While I understand
the value of printf() compatibility, one of the key differentiators with
iostreams is type safety, which is effectively broken with the current behavior.
If we wanted to preserve printf() like behavior then 'cout << hex << "some
string"' should print out the address of the string literal in hex, rather than
the string literal's contents, ignoring the hex flag completely.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23757