[gnu.g++.bug] g++ 1.36.2 inconsistency

whitcomb@VIVALDI.BERKELEY.EDU (Gregg Whitcomb) (01/11/90)

old version: 1.35.0+ on a vax/ultrix, libg++ 1.35 (I think)

new version: 1.36.2 on a decstation (this probably isn't machine specific)
   libg++ 1.36.2

description: order of type conversion is difference.  Old version
   converts "x" to a String using the String operator of class X.
   New version converts "x" to an int using the int operator of class X
   and then converts the int to a String using the int operator of String.
   Also, old version doesn't accept ambiguous conversion for x for << operator,
   new version does.

----- teststr.cc

#include <String.h>
#include <stream.h>

class X
   {
   int a;
public:
   X(int v) {a = v;}
   operator String() {return String("$") + String(itoa(a));}
   operator int() {return a;}
   };

main()
{
   X x(42);
#ifdef OLDVERSION
   cout << String(x) << ":" << "\n";
#else
   cout << String(x) << ":" << x << "\n";
#endif
}

----- new version compile/run

vivaldi% g++ teststr.cc
teststr.cc: In method X::operator class String ():
teststr.cc:9: warning: function too large to be inline
vivaldi% a.out
*:42

----- old version compile/run
g++ -DOLDVERSION teststr.cc
eros% a.out
$42:



-Gregg (whitcomb@vivaldi.Berkeley.EDU)