This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/5073: Problem with C++ style string and setw() manipulator



>Number:         5073
>Category:       libstdc++
>Synopsis:       Problem with C++ style string and setw() manipulator
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 11 07:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Thierry De Corte
>Release:        g++ 2.96
>Organization:
>Environment:
Linux Mandrake 8.0 with g++ 2.96
>Description:
The manipulator setw() is working with C style strings but not with C++ style strings.

Based on the standard, setw() is suposed to be working to both C and C++ style strings.
>How-To-Repeat:
#include <string>
#include <iomanip>
#include <iostream>
 
int main(void)
{
	string my_str("Hello");
	string my_str2("bye");
	
    // The correct expected result was "Hello      bye"
    // The actual buggy result is: "Hellobye"
	cout.setf(ios::left, ios::adjustfield);
	cout << setw(20) << my_str << my_str2 << endl;

	return 1;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cpp"

I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4K
IAppbnQgbWFpbih2b2lkKQp7CglzdHJpbmcgbXlfc3RyKCJIZWxsbyIpOwoJc3RyaW5nIG15X3N0
cjIoImJ5ZSIpOwoJCiAgICAvLyBUaGUgY29ycmVjdCBleHBlY3RlZCByZXN1bHQgd2FzICJIZWxs
byAgICAgIGJ5ZSIKICAgIC8vIFRoZSBhY3R1YWwgYnVnZ3kgcmVzdWx0IGlzOiAiSGVsbG9ieWUi
Cgljb3V0LnNldGYoaW9zOjpsZWZ0LCBpb3M6OmFkanVzdGZpZWxkKTsKCWNvdXQgPDwgc2V0dygy
MCkgPDwgbXlfc3RyIDw8IG15X3N0cjIgPDwgZW5kbDsKCglyZXR1cm4gMTsKfQo=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]