http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51667
--- Comment #3 from Uros Bizjak <ubizjak at gmail dot com> 2011-12-24 08:00:38 UTC --- Following testcase shows the problem in libstdc++: --cut here-- #include <iostream> #include <sstream> #include <cassert> void test01() { using namespace std; stringstream ostr1; ostr1.setf(ios_base::oct); ostr1.setf(ios_base::hex); short s = -1; ostr1 << s; cout << "result: " << ostr1.str() << endl; assert( ostr1.str() == "-1" ); } int main() { test01(); return 0; } --cut here-- [uros@localhost test]$ ./a.out result: 65535 a.out: 7.cc:19: void test01(): Assertion `ostr1.str() == "-1"' failed. Aborted Sign-extension from short is missing somewhere.