[ROOT] Handling of implicit conversions and/or operator<<(ostream&, bool)

From: Walter F.J. Mueller (w.f.j.mueller@gsi.de)
Date: Tue Nov 27 2001 - 22:43:01 MET


Hi,

I would expect that `<<`ing a bool to cout prints a 0 or 1 for a 
variable containing false and true, respectively. This isn't true
for CINT 5.15.17 in ROOT 3.02/03. The simple macro

void trial() 
{
  float f = 1.;
  for (int i = 0; i < 48; i++) {
    bool b = f;
    cout << "b = " << b << " f = " << f << endl;
    f *= 2.;
  }
  return;
}

gives when interpreted by CINT

   b = 1 f = 1
   b = 2 f = 2
   b = 4 f = 4
   ...
   b = -2147483648 f = 1.40737e+14

while when ACLiC'ed I get

   b = 1 f = 1
   b = 1 f = 2
   ...
   b = 1 f = 1.40737e+14

I don't know whether the implementation of operator<<(ostream&, bool)
or the way the implicit conversion to bool is done is to blame. At 
least both don't seem to work together well.

			Cheers,	Walter
--
Walter F.J. Mueller   Mail:  W.F.J.Mueller@gsi.de
GSI,  Abteilung KP3   Phone: +49-6159-71-2766
D-64291 Darmstadt     FAX:   +49-6159-71-2989
WWW:   http://www-kp3.gsi.de/www/kp3/people/mueller.html
PGP:   http://www-kp3.gsi.de/~mueller/pgp.shtml



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET