🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

type conversion bug in g++ 1.36.3 (machine dependent)

#719
From: Gregg Whitcomb
Date: Mon, 15 Jan 1990 22:38
121 lines
3968 bytes
the following code produces a type conversion error in the decstation 3100
g++, but not with the vax version.  

machine: vax/ultrix 4.0 and decstation
g++: 1.36.3
libg++: 1.36.2
gcc: 1.36.92

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

class X
   {
   int a;
public:
   X(int v) {a = v;}
   X(String str);

#ifdef BUG
   friend inline X operator <<(X& x, X& y) {return x.a << y.a;}
#else
   friend inline X operator !=(X& x, X& y) {return x.a != y.a;}
#endif

   operator String() {return String("$") + String(itoa(a));}
   operator int() {return a;}
   friend ostream& operator<<(ostream& s, X& x);
   };

----------
teststr3.cc
----------
#include "teststr3.h"

X::X(String str)
{
   a = atoi(str);
}

ostream& operator<<(ostream& s, X& x)
{
   s <<  String(x) << "#";
   return s;
}
main()
{
   X x(42);
#ifdef OLDVERSION
   cout << String(x) << ":" << "\n";
#else
   cout << String(x) << ":" << x << ":" << int(x) << "\n";
#endif
}

-------- vax compile -------
ic% g++ -v -DBUG teststr3.cc
g++ version 1.36.3 (based on GCC 1.36.92)
 /usr/local/lib/gcc-cpp -+ -v -DBUG -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -
Dvax -Dunix -D__vax__ -D__unix__ teststr3.cc /usr/tmp/cca13754.cpp
GNU CPP version 1.36.92
 /usr/local/lib/gcc-cc1plus /usr/tmp/cca13754.cpp -quiet -dumpbase teststr3.cc -
version -o /usr/tmp/cca13754.s
GNU C++ version 1.36.3 (based on GCC 1.36.92) (vax) compiled by GNU C version 1.
36.92.
default target switches: -munix
 /usr/local/lib/gcc-as -o teststr3.o /usr/tmp/cca13754.s
 /usr/local/lib/gcc-ld /lib/crt0.o teststr3.o -lg++ /usr/local/lib/gcc-gnulib -l
c
ic% a.out
$42:$42#:42
ic%

------- decstation compile --------
vivaldi% g++ -v -DBUG teststr3.cc
g++ version 1.36.3 (based on GCC 1.36.92)
 /usr/local/lib/gcc-cpp -+ -v -DBUG -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -
Dultrix -Dbsd4_2 -DMIPSEL -Dhost_mips -Dmips -Dunix -DR3000 -DLANGUAGE_C -DSYSTY
PE_BSD -D__ultrix__ -D__bsd4_2__ -D__MIPSEL__ -D__host_mips__ -D__mips__ -D__uni
x__ -D__R3000__ -D__LANGUAGE_C__ -D__SYSTYPE_BSD__ teststr3.cc /usr/tmp/cca15059
.cpp
GNU CPP version 1.36.92
 /usr/local/lib/gcc-cc1plus /usr/tmp/cca15059.cpp -quiet -dumpbase teststr3.cc -
version -o /usr/tmp/cca15059.s
GNU C++ version 1.36.3 (based on GCC 1.36.92) (AL-MIPS 1.11) <Decstation>
 compiled by GNU C version 1.36.92.
default target switches: -munix -mnofixed-ovfl -mG0 -mG1
teststr3.h: In method X::operator class String ():
In file included from teststr3.cc:1:
teststr3.h:17: warning: function too large to be inline
teststr3.cc: In function class ostream &operator << (class ostream &, class X &)
:
teststr3.cc:10: ambiguous type conversion requested for method `operator <<'
teststr3.cc: In function int main ():
teststr3.cc:19: ambiguous type conversion requested for method `operator <<'
vivaldi%

------ decstation compile (minus "BUG") code -----
vivaldi% g++ teststr3.cc
teststr3.h: In method X::operator class String ():
In file included from teststr3.cc:1:
teststr3.h:17: warning: function too large to be inline
vivaldi%

------ decstation compile (minus X(String str) function) -----
vivaldi% g++ -DBUG teststr3.cc
teststr3.h: In method X::operator class String ():
In file included from teststr3.cc:1:
teststr3.h:17: warning: function too large to be inline
vivaldi%




-------------


-Gregg (whitcomb@vivaldi.berkeley.edu)
Technical Details
Message-ID: <9001152238.AA15120@vivaldi.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!bu.edu!bu-cs!lll-winken!uwm.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!clyde.concordia.ca!uunet!bu.edu!bu-cs!lll-winken!uwm.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: type conversion bug in g++ 1.36.3 (machine dependent)
Message-ID: <9001152238.AA15120@vivaldi.Berkeley.EDU>
Date: 15 Jan 90 22:38:03 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 121