home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / gnu / gcc / bug / 3006 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.1 KB  |  68 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!bms88.bmsi.COM!stuart
  3. From: stuart@bms88.bmsi.COM (Stuart D. Gathman)
  4. Subject: bug in g++2.3.2
  5. Message-ID: <9212161901.AA07940@bms88.BMSI.COM>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Thu, 17 Dec 1992 00:01:48 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 55
  12.  
  13. The following (short extract of a) program causes cc1plus to use an
  14. infinite amount of virtual memory while expanding Money FNUM<2>::operator--().
  15.  
  16. While returning Money(*this) fixes this short test program, all my programs
  17. using templates similar to FNUM crash the 2.3.2 compiler.  The 2.2.2 compiler
  18. compiles them correctly (including this test program).
  19.  
  20. Output of g++ -v:
  21.  
  22.       Reading specs from /usr/local/lib/gcc-lib/delta88/2.3.2/specs
  23.       gcc version 2.3.2
  24.  
  25. delta88 is basically m88k-motorola-sysv3 with about a dozen lines of
  26. config/m88kv3.h hacked to use .ctor and .dtor segments (each consisting
  27. of a null terminated list of function pointers) rather than
  28. the .init segment.
  29.  
  30. The test program:
  31. -------------------------test.cc-------------------------------
  32. class Money {
  33.   long high;
  34.   unsigned short low;
  35. public:
  36.   Money(long = 0);
  37.   Money(const Money &m): high(m.high), low(m.low) {}
  38.   Money(const char *,int = 6);        
  39.   void store(char *,int = 6) const;
  40.   Money &operator -=(const Money &);
  41.   Money operator -(const Money &a) const { Money t(a); return t -= *this; }
  42. };
  43.  
  44. template <int size> class FNUM {
  45.   char num[size];
  46. public:
  47.   FNUM() { memset(num,0,size); }
  48.   FNUM & operator = (const Money &m) { m.store(num,size); return *this; }
  49.   FNUM & operator = (FNUM &a) {
  50.     memcpy(num,a.num,size);
  51.     return *this;
  52.   }
  53.   operator Money() const { return Money(num,size); }
  54.   Money operator --() { *this = Money(num,size) - 1L; return *this; }
  55. };
  56.  
  57. struct DataDict {
  58.   FNUM<2>    line;    
  59. };
  60. ---------------------------------------------------
  61. Output of cc1plus (interrupted before "virtual memory exhausted" error):
  62.  
  63. Money::Money (const class Money&) class Money Money::operator - (const class Money&)const  class Money FNUM<2>::operator -- ()
  64.  
  65.  
  66.     stuart@bmsi.com
  67.  
  68.