Article View: gnu.g++.lib.bug
Article #448Re: 2.3: ios::showpos overeager on unsigneds
From: bothner
Date: Thu, 21 Jan 1993 23:21
Date: Thu, 21 Jan 1993 23:21
39 lines
1757 bytes
1757 bytes
> A careful reading of Stroustrup, "C++ prog lang", 2nd ed., page 340
> indicates that the showpos attribute of an ostream causes the printing
> of '+' signs for positive ints.
Do not count on Stroustrup to be accurate or complete when it comes
to the iostream library.
> With Sun C++, this program
> ======================================================================
> #include <iostream.h>
>
> int main(int, char*[])
> {
> unsigned u = 1;
> cout.setf(ios::showpos);
> cout << u << endl;
> return 0;
> }
> ======================================================================
> prints
> 1
> as seems appropriate, since u is not a positive int. With (patched)
> g++-2.3.3 and (patched) libg++-2.3, the same program prints
> +1
I disagee: 1 is a positive int.
However, my ANSI draft is unclear. It says:
If i is positive and showpos is on, decimal conversion converts
it to a plus signed (+) followed by decimal digits. The other
conversions treat all values as unsigned.
It might *possibly* be interpreted to imply that unsigned conversion
should not show a '+'. I don't think that is the most natural
interpretation, but I will ask for a clarification.
--Per Bothner
Cygnus Support bothner@cygnus.com
Technical Details
Message-ID:
<9301212052.AA15114@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!bothnerReferences:
<9301201711.AA25469@cs.rice.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!bothner From: bothner@cygnus.com Newsgroups: gnu.g++.lib.bug Subject: Re: 2.3: ios::showpos overeager on unsigneds Date: 21 Jan 1993 18:21:34 -0500 Organization: GNUs Not Usenet Lines: 40 Sender: daemon@cis.ohio-state.edu Approved: bug-lib-g++@prep.ai.mit.edu Distribution: gnu Message-ID: <9301212052.AA15114@cygnus.com> References: <9301201711.AA25469@cs.rice.edu>