Details
[Home]
Issue of the Implementation # S0677
Brief
num_put<>::do_put(void*) performs padding incorrectly when adjustfield==internal
Detailed Description
The following member function of num_put<char> and num_put<wchar_t>
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const
incorrectly performs padding of a string to bring its length to the required value if 'adjustfield' flag is equal to 'internal': instead of adding fill characters after "0x" it adds them at the beginning of the string
According to the description of padding options (22.2.2.2.2 p19), if
adjustfield == internal and representation after stage 1 began with 0x or 0X - pad after x or X.The example below demonstrates the problem (the output of numbers to cout is implemented using num_get<> facet).
In this example " 0x1" is output to the standard output stream while it should be "0x 1" according to the standard.
Problem location(s) in the standard
Linux Standard Base C++ Specification 3.2, Chapter 9. Libraries, 9.1. Interfaces for libstdcxx that refers ISO/IEC 14882: 2003 Programming languages -- C++, section 22.2.2.2.2
Example
#include <iostream> #include <locale> using namespace std; int main() { void *p = (void*)0x1; cout.width(5); cout << internal << p << endl; // " 0x1" will be output while it should be "0x 1" return 0; }
Component
libstdc++
Accepted
GCC Bugzilla 38210
Status
Fixed in gcc-4.4.0
[Home]