From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530 Description of problem: Using std::iomanip on std::ostream with std::string to pad output does not work the same as it does for char*. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: #include <iostream> #include <iomanip> #include <sstream> using namespace std; main() { char* c("CHAR"); string s("STRING"); { ostringstream buffer; cout << "In a 10 char wide field:\n"; buffer << "|" << setw(10) << c << "|"; cout << buffer.str() << "\t"; } { ostringstream buffer; buffer << "|" << setw(10) << s << "|"; cout << buffer.str(); } cout << "\n\n"; { ostringstream buffer; cout << "In a 10 char wide field, left justified:\n"; buffer << "|"; buffer.setf(ios::left); buffer << setw(10) << c << "|"; cout << buffer.str() << "\t"; } { ostringstream buffer; buffer << "|"; buffer.setf(ios::left); buffer << setw(10) << s << "|"; cout << buffer.str(); } cout << "\n\n"; { ostringstream buffer; cout << "In a 10 char wide field, left justified, zero padded:\n"; buffer << "|"; buffer.setf(ios::left); buffer << setw(10) << setfill('0') << c << "|"; cout << buffer.str() << "\t"; } { ostringstream buffer; buffer << "|"; buffer.setf(ios::left); buffer << setw(10) << setfill('0') << s << "|"; cout << buffer.str(); } cout << "\n\n"; } Actual Results: In a 10 char wide field: | CHAR| |STRING | char* and std::string output do not match: In a 10 char wide field, left justified: |CHAR | |STRING| In a 10 char wide field, left justified, zero padded: |CHAR000000| |STRING|000000000 Expected Results: char* and std::string output should be padded similarly. Additional info: Before entering this bug here, I posted to comp.lang.c++ and my first response was from P.J. Plauger himself, who agrees this is aberrant behavior. The attached URL is for the thread for that post on Google Groups.
Fixed 3.2.3, 3.3.x, 3.4.x.