🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1551

bug in g++2.3.2

#1551
From: Stuart D. Gathman
Date: Thu, 17 Dec 1992 00:01
54 lines
2201 bytes
The following (short extract of a) program causes cc1plus to use an
infinite amount of virtual memory while expanding Money FNUM<2>::operator--().

While returning Money(*this) fixes this short test program, all my programs
using templates similar to FNUM crash the 2.3.2 compiler.  The 2.2.2 compiler
compiles them correctly (including this test program).

Output of g++ -v:

      Reading specs from /usr/local/lib/gcc-lib/delta88/2.3.2/specs
      gcc version 2.3.2

delta88 is basically m88k-motorola-sysv3 with about a dozen lines of
config/m88kv3.h hacked to use .ctor and .dtor segments (each consisting
of a null terminated list of function pointers) rather than
the .init segment.

The test program:
-------------------------test.cc-------------------------------
class Money {
  long high;
  unsigned short low;
public:
  Money(long = 0);
  Money(const Money &m): high(m.high), low(m.low) {}
  Money(const char *,int = 6);		
  void store(char *,int = 6) const;
  Money &operator -=(const Money &);
  Money operator -(const Money &a) const { Money t(a); return t -= *this; }
};

template <int size> class FNUM {
  char num[size];
public:
  FNUM() { memset(num,0,size); }
  FNUM & operator = (const Money &m) { m.store(num,size); return *this; }
  FNUM & operator = (FNUM &a) {
    memcpy(num,a.num,size);
    return *this;
  }
  operator Money() const { return Money(num,size); }
  Money operator --() { *this = Money(num,size) - 1L; return *this; }
};

struct DataDict {
  FNUM<2>	line;	
};
---------------------------------------------------
Output of cc1plus (interrupted before "virtual memory exhausted" error):

Money::Money (const class Money&) class Money Money::operator - (const class Money&)const  class Money FNUM<2>::operator -- ()


	stuart@bmsi.com
Technical Details
Message-ID: <9212161901.AA07940@bms88.BMSI.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!bms88.bmsi.COM!stuart

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!bms88.bmsi.COM!stuart
From: stuart@bms88.bmsi.COM (Stuart D. Gathman)
Subject: bug in g++2.3.2
Message-ID: <9212161901.AA07940@bms88.BMSI.COM>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 17 Dec 1992 00:01:48 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 55