Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by Craig Ruff
Wed, 27 Jan 1993 03:17
Possible output field adjustment bug
Author: Craig Ruff
Date: Wed, 27 Jan 1993 03:17
Date: Wed, 27 Jan 1993 03:17
37 lines
1410 bytes
1410 bytes
I have found a possible bug in the field adjustment operators of the stream
class. The following program:
#include <iostream.h>
main()
{
cout.width(4);
cout << '(' << -12 << ")\n";
cout.width(4);
cout.setf(ios::left, ios::adjustfield);
cout << '(' << -12 << ")\n";
cout.width(4);
cout.setf(ios::internal, ios::adjustfield);
cout << '(' << -12 << ")\n";
}
Produces:
(-12)
( -12)
(-12)
According to page 343 of Stroustrup's "The C++ Programming Language", 2nd
edition it should produce:
( -12)
(-12 )
(- 12)
The width function should apply to the next numeric or string output
operation, not to characters. Now, to me, it would seem that symmetric
operation of the field adjustments are desirable. Is this the intent
of the libg++ versions?
Craig Ruff NCAR cruff@ncar.ucar.edu
(303) 497-1211 P.O. Box 3000
Boulder, CO 80307
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