c++/1805: formated 'cout'-output is wrong
alexander.kuchler@pruftechnik.com
alexander.kuchler@pruftechnik.com
Mon Jan 29 08:06:00 GMT 2001
>Number: 1805
>Category: c++
>Synopsis: formated 'cout'-output is wrong
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Jan 29 08:06:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Alexander Kuchler
>Release: unknown-1.0
>Organization:
>Environment:
gcc 2.95.2; libs from SuSE 7.0; Athlon;
(Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release))
>Description:
Formating "cout"-output doesn't work correct with
string-variables.
what works is:
>How-To-Repeat:
Test File HW.cpp like follows:
g++ -Wall HW.cpp -o hw
hw
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
>cout.setf(ios::right);
>cout << setw(20) << "Hello World";
output is:
Hello World
what not works is:
>string x="Hello World";
>cout.setf(ios::right);
>cout << setw(20) << x;
output is:
Hello World
----gnatsweb-attachment----
Content-Type: application/octet-stream; name=""HW.cpp""; name="HW.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="HW.cpp"
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHN0cmluZz4K
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewoJY291dC5zZXRmKGlvczo6cmlnaHQp
OwoJY291dCA8PCBzZXR3KDIwKSA8PCAiSGVsbG8gV29ybGQiOwoKCWNvdXQgPDwgZW5kbDsKCQoJ
c3RyaW5nIHg9IkhlbGxvIFdvcmxkIjsKCWNvdXQuc2V0Zihpb3M6OnJpZ2h0KTsKCWNvdXQgPDwg
c2V0dygyMCkgPDwgeDsKCWNvdXQgPDwgZW5kbDsKCXJldHVybigwKTsKfQo=
More information about the Gcc-bugs
mailing list