🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.lib.bug
Article #236

does it bug of ostream.form()

#236
From: Onizuka "Creole" Kentaro
Date: Thu, 27 Aug 1992 12:38
66 lines
1889 bytes
I found a very interesting bug in libg++-2.2.
Machine is IRIS 4D/VGX with IRIX 4.0.1

1: 

The output of this tiny program is a little bit strange.
#include <stream.h>

main()
{
  cout << form(" %10.5f\n",21.0);
  cout << form(" %10.5f\n",20.0);
  cout << form(" %10.5f\n",21.0);
  cout << form(" %10.5f\n",20.0);
  cout << form(" %10.5f\n",21.0);
  cout << form(" %10.5f\n",20.0);
  cout << form(" %10.5f\n",21.0);
  cout << form(" %10.5f\n",20.0);
  cout << form(" %10.5f\n",21.0);
}

Output is,

   21.00000
   20.000000 <- here 
   21.00000
   20.000000 <- here 
   21.00000
   20.000000 <- here 
   21.00000
   20.000000 <- here 
   21.00000

Only when form() output 20.0, the format changes.

2:

This is another bug. Because I don't want such a dirty format above, I
changed the "cout << form()" to "printf()" then interesting accident
took place

#include <stdio.h>
#include <stream.h>

main()
{
  for(int I = 0;I<10;++I)
    {
      cout << "A";
      printf("B");
    }
}

Output of this program is,

AAAAAAAAAABBBBBBBBBB

I think everyone will expect the output below.

ABABABABABABABABABAB

or are these strangeness specification?
--
.Kentaro Onizuka .... Institute for New Generation Computer Technology ...
......................................E-mail  onizuka@icot.or.jp .........
..Mi waan mek star ship! Mi waan go Mars! Dat mi drim! .....(i) x13.(s)x3.
Technical Details
Message-ID: <ONIZUKA.92Aug27213819@psiux535.icot.or.jp>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!icot.or.jp!onizuka

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!icot.or.jp!onizuka
From: onizuka@icot.or.jp (Onizuka "Creole" Kentaro)
Subject: does it bug of ostream.form()
Message-ID: <ONIZUKA.92Aug27213819@psiux535.icot.or.jp>
Sender: gnulists@ai.mit.edu
Organization: Institute for New Generation Computer Technology, Tokyo, Japan
Distribution: gnu
Date: Thu, 27 Aug 1992 12:38:19 GMT
Approved: bug-lib-g++@prep.ai.mit.edu
Lines: 70