🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #2155

g++ 1.36.2 inconsistency (with older version)

#2155
From: Gregg Whitcomb
Date: Thu, 11 Jan 1990 02:16
53 lines
1663 bytes
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)
Technical Details
Message-ID: <9001110216.AA15866@vivaldi.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!VIVALDI.BERKELEY.EDU!whitcomb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!VIVALDI.BERKELEY.EDU!whitcomb
From: whitcomb@VIVALDI.BERKELEY.EDU (Gregg Whitcomb)
Newsgroups: gnu.g++.bug
Subject: g++ 1.36.2 inconsistency (with older version)
Message-ID: <9001110216.AA15866@vivaldi.Berkeley.EDU>
Date: 11 Jan 90 02:16:29 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 53