This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10159: setiosflags(ios::right) is broken
- From: rppawlo at sandia dot gov
- To: gcc-gnats at gcc dot gnu dot org
- Date: 20 Mar 2003 02:04:48 -0000
- Subject: c++/10159: setiosflags(ios::right) is broken
- Reply-to: rppawlo at sandia dot gov
>Number: 10159
>Category: c++
>Synopsis: setiosflags(ios::right) is broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 20 02:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: rppawlo at sandia dot gov
>Release: unknown-1.0
>Organization:
>Environment:
debian-gnu linux 2.4.19
>Description:
Once you use the line setiosflags(ios::right) then
subsequent calls to setiosflags(ios::left) do not work.
It get stuck on right only. The following code demonstrates
this:
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
//using std::ostream;
int main(int argc, char *argv[]) {
cout << setiosflags(ios::left) << setw(15) << setfill('.');
cout << "Converged";
cout << "YES" << endl;
cout << setiosflags(ios::right) << setfill('*');
cout << endl;
cout << setiosflags(ios::left) << setw(15) << setfill('.');
cout << "Converged";
cout << "YES" << endl;
return 0;
}
If I compile with:
g++ (GCC) 3.2.3 20030309 (Debian prerelease)
the output is:
mythdrannor 18:47 > a.out
Converged......YES
......ConvergedYES
If I run with g++ version 2.95 the correct output is given:
mythdrannor 18:47 > a.out
Converged......YES
Converged......YES
I am running debian linux with the 3.2 compilers currently
in the unstable branch.
>How-To-Repeat:
See attached file. Compile and run with 2.95 to see the
correct output. g++-3.2 give a reversed output for the
final print statement.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="main.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="main.C"
I2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8aW9zdHJlYW0+
CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Ci8vdXNpbmcgc3RkOjpvc3RyZWFtOwppbnQgbWFpbihpbnQg
YXJnYywgY2hhciAqYXJndltdKSB7CgogIGNvdXQgPDwgc2V0aW9zZmxhZ3MoaW9zOjpsZWZ0KSA8
PCBzZXR3KDE1KSA8PCBzZXRmaWxsKCcuJyk7CiAgY291dCA8PCAiQ29udmVyZ2VkIjsKICBjb3V0
IDw8ICJZRVMiIDw8IGVuZGw7CgogIGNvdXQgPDwgc2V0aW9zZmxhZ3MoaW9zOjpyaWdodCkgPDwg
c2V0ZmlsbCgnKicpOwogIGNvdXQgPDwgZW5kbDsKCiAgY291dCA8PCBzZXRpb3NmbGFncyhpb3M6
OmxlZnQpIDw8IHNldHcoMTUpIDw8IHNldGZpbGwoJy4nKTsKICBjb3V0IDw8ICJDb252ZXJnZWQi
OwogIGNvdXQgPDwgIllFUyIgPDwgZW5kbDsKICByZXR1cm4gMDsKfQo=