🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Stuart D. Gathman Thu, 17 Dec 1992 00:01
bug in g++2.3.2
#1551
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads