public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/28278] formatted I/O and calliing width(0)
       [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-27 11:26 ` mikeus at hotmail dot ru
  2010-12-27 12:12 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: mikeus at hotmail dot ru @ 2010-12-27 11:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28278

Michael <mikeus at hotmail dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikeus at hotmail dot ru

--- Comment #1 from Michael <mikeus at hotmail dot ru> 2010-12-27 11:25:51 UTC ---
Can anybody fix this bug?

------- code: -------
#include<iostream>
using namespace std;

int main()
{
  cout.setf(ios_base::fixed);
  cout.precision(3);
  cout.width(20);
  cout.fill('#');

  cout << (double)1.123456789 << endl;
  cout << (double)0.123456789 << endl;
  cout << (double)10.123456789 << endl;
}
---------------------

------- output: -------
###############1.123
0.123
10.123
-----------------------

------- expected: -------
###############1.123
###############0.123
##############10.123
-------------------------

It's just sad... :^(((


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/28278] formatted I/O and calliing width(0)
       [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
  2010-12-27 11:26 ` [Bug libstdc++/28278] formatted I/O and calliing width(0) mikeus at hotmail dot ru
@ 2010-12-27 12:12 ` paolo.carlini at oracle dot com
  2010-12-27 14:31 ` [Bug libstdc++/28278] formatted I/O and calling width(0) redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-12-27 12:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28278

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-12-27 12:12:13 UTC ---
The snippet you posted has nothing to do with the issue discussed here, which
is about *when exactly* calling width(0) toward the end of the insertion
operation (there are minor inconsistencies in the Standard detectable when the
insertion proper throws). But in any case, per the letter of both C++03 and
C++0x , during the arithmetic insertion at some point width(0) has to be
called, normally by the num_put facet in Stage 3. Thus the behavior we are
implementing vs your snippet is already Ok, no bug to fix (if you want a
practical check, Sun Studio behaves the same).


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/28278] formatted I/O and calling width(0)
       [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
  2010-12-27 11:26 ` [Bug libstdc++/28278] formatted I/O and calliing width(0) mikeus at hotmail dot ru
  2010-12-27 12:12 ` paolo.carlini at oracle dot com
@ 2010-12-27 14:31 ` redi at gcc dot gnu.org
  2010-12-27 15:13 ` mikeus at hotmail dot ru
  2023-12-02  0:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2010-12-27 14:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28278

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-27 14:31:39 UTC ---
(In reply to comment #1)
> Can anybody fix this bug?

Don't be sad, your bug is easy to fix:

> ------- code: -------
> #include<iostream>
> using namespace std;
> 
> int main()
> {
>   cout.setf(ios_base::fixed);
>   cout.precision(3);
>   cout.width(20);
>   cout.fill('#');
> 
   cout << std::setw(20) << 1.123456789 << endl;
   cout << std::setw(20) << 0.123456789 << endl;
   cout << std::setw(20) << 10.123456789 << endl;
> }

Fixed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/28278] formatted I/O and calling width(0)
       [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-12-27 14:31 ` [Bug libstdc++/28278] formatted I/O and calling width(0) redi at gcc dot gnu.org
@ 2010-12-27 15:13 ` mikeus at hotmail dot ru
  2023-12-02  0:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: mikeus at hotmail dot ru @ 2010-12-27 15:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28278

--- Comment #4 from Michael <mikeus at hotmail dot ru> 2010-12-27 15:12:50 UTC ---
:))OK.
( I merely have looked at 'ios_base state functions' chapter in C++0x draft and
not found any mention that any preset state of a stream may be lost after an
output operation.  It turns out that the width is the (only) state which can
be(inconsequently) lost after an output operation. )


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/28278] formatted I/O and calling width(0)
       [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-12-27 15:13 ` mikeus at hotmail dot ru
@ 2023-12-02  0:33 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2023-12-02  0:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28278

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 56765
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56765&action=edit
Martin's test code

Attaching the test code here, in case the link stops working.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-02  0:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-28278-4@http.gcc.gnu.org/bugzilla/>
2010-12-27 11:26 ` [Bug libstdc++/28278] formatted I/O and calliing width(0) mikeus at hotmail dot ru
2010-12-27 12:12 ` paolo.carlini at oracle dot com
2010-12-27 14:31 ` [Bug libstdc++/28278] formatted I/O and calling width(0) redi at gcc dot gnu.org
2010-12-27 15:13 ` mikeus at hotmail dot ru
2023-12-02  0:33 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).