🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Possible bug with Integer Class

#502
From: tower
Date: Thu, 20 Apr 1989 22:48
44 lines
2012 bytes
   Config.g++ sun3, no FPA used at all. G++ 1.34.2, libg++ 1.34.0
   all with gcc 1.34. On SUN3-/160, I get the following.
   Gordon.
   
   
   karl:/stats/staff/karl/gordon/c++/otto/table.gnu[17] g++ -c fib.try.cc
   In function struct Integer fib (int):
   fib.try.cc:17: aggregate type mismatch in conditional expression
   karl:/stats/staff/karl/gordon/c++/otto/table.gnu[18] cat !$
   cat fib.try.cc
   //
   // Example for B11b - of use of tables.
   //
   // A memo-ising function - using doubly recursive fibonacci as example
   //
   //					G. P. Otto, 1987
   
   #include	"table.h"
   
   static table fibresults;			// table of known results
   
   Integer
   fib(int n)
   {
	   Integer res = fibresults.lookup(n);	// lookup answer
	   if (!fibresults.lastlookupOK){		// if not yet known
   /* BUG? */	res = (n < 2)? Integer(1) : (fib(n-1) + fib(n-2));	// calculate it
		   fibresults.insert(n,res);		// and note the result
	   }
	   return(res);
   }
   
I can tell you why you get this error: because Integer(1) returns an
object of type Integer, and Integer+Integer returns an object of type
IntTmp.  I will fix the compiler to deal with this problem.  In the
mean time, I am not sure whether I should have the compiler try to
guess what it is supposed to do, or to suggest that you cast the
result of the + operator to Integer.  I will fix the compiler to give
a more instructive error message.

Aside to dl: this is what happens when classes get too smart...

Michael
Technical Details
Message-ID: <8904202248.AA16173@wheat-chex.ai.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!WHEATIES.AI.MIT.EDU!tower
References: <8904111444.AA11338@prep.ai.mit.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!WHEATIES.AI.MIT.EDU!tower
From: tower@WHEATIES.AI.MIT.EDU
Newsgroups: gnu.g++.lib.bug
Subject: Possible bug with Integer Class
Message-ID: <8904202248.AA16173@wheat-chex.ai.mit.edu>
Date: 20 Apr 89 22:48:09 GMT
References: <8904111444.AA11338@prep.ai.mit.edu>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@wheaties.ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 44