Thread View: gnu.g++.lib.bug
2 messages
2 total messages
Started by Lack Mr G M
Tue, 05 Jan 1993 17:22
Bug in libg++-2.3 (using setfill/setw in iomanip).
Author: Lack Mr G M
Date: Tue, 05 Jan 1993 17:22
Date: Tue, 05 Jan 1993 17:22
41 lines
1804 bytes
1804 bytes
I have just built libg++-2.3 on both a Sun SparcStation (SunOS
4.1.1) and an SG Indigo (Irix 4.0.1) using gcc-2.3.3 and have discovered
what I think is a bug in the newly-added manipulators in iomanip.h.
To test the setw/setfill I used trivial example from 3/4 down p348
of Stroustrup's "The C++ Programming Language" Second Edition (this is
in section 10.4.2.1). Here is the entire code...
============================== Test Source ===========================
#include <iostream.h>
#include <iomanip.h>
int main()
{
cout << setw(4) << setfill('#') << '(' << 12 << ")\n";
cout << '(' << 12 << ")\n";
return 0;
}
============================ End Test Source =========================
The output expected is:
(##12)
(12)
but I get
###(12)
(12)
from which I infer that the setw(4) and setfill('#') are being used
for the output of '('. In 10.4.1.2 Stroustrup that these specifications
should apply to the "next numeric or string" output operation. '(' is a
char and so shouldn't be affected.
NOTE: AT&T's cfront 2.1 agrees with Stroustrup on this. I checked...
-------------------------- Gordon Lack ----------------------------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
Re: Bug in libg++-2.3 (using setfill/setw in iomanip).
Author: bothner
Date: Tue, 05 Jan 1993 16:20
Date: Tue, 05 Jan 1993 16:20
17 lines
1121 bytes
1121 bytes
> have discovered > what I think is a bug in the newly-added manipulators in iomanip.h. No, the problem is in ostream::operator<<(char), and is old. The problem is that I followed the documentation (the AT&T man pages, and the draft ANSI standard), while AT&T felt no such obligation to follow their own documentation. I will probably change my code, assuming the ANSI draft gets modified. But thanks for trying this out - there was a question whether ANSI should follow the AT&T documentation or their implementation; being able to point to an example in Stroustrup's book would tend to favor the latter. --Per Bothner Cygnus Support bothner@cygnus.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads