home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / bug / 2305 < prev    next >
Encoding:
Text File  |  1993-01-21  |  3.2 KB  |  119 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!inf-technik.tu-ilmenau.DE!Karsten.Pahnke
  2. From: Karsten.Pahnke@inf-technik.tu-ilmenau.DE (Karsten Pahnke)
  3. Newsgroups: gnu.g++.bug
  4. Subject: operator++
  5. Date: 21 Jan 1993 18:07:53 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 106
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301211109.AA27664@pegasus.inf-technik.tu-ilmenau.de>
  12.  
  13. Hallo gnu--developers,
  14.  
  15. I have two problems with the g++2.3.3:
  16.  
  17. 1.) The compiler does not distinct pre- and postfix versions
  18.     of increment and decrement operators. 
  19.     I think this is a difference to the ARM.
  20.  
  21. Here a small example:
  22. ----------------cut here--------------------------------------------------
  23. #include <iostream.h>
  24.  
  25. class Integer {
  26. private:
  27.     int _val;
  28. public:
  29.     Integer(int val = 0) {_val = val;}
  30.  
  31.     int    operator++()    { _val++; return _val; }
  32.     int    operator++(int)    { int temp = _val; _val++; return temp; }
  33.     operator int() const    { return _val; }
  34. };
  35.  
  36. main()
  37. {
  38.     Integer i(5);
  39.     cout << "i  : " << i << endl;
  40.     cout << "i++: 5 5 6 ok" << endl;
  41.     cout << "i++: " << i << ' ' << i++ << ' ' << i << endl;
  42.     cout << "++i: 6 7 7 ok" << endl;
  43.     cout << "++i: " << i << ' ' << ++i << ' ' << i << endl;
  44. }
  45.  
  46. ----------------cut here--------------------------------------------------
  47. the executable produces the following output:
  48. i  : 5
  49. i++: 5 5 6 ok
  50. i++: 5 6 6
  51. ++i: 6 7 7 ok
  52. ++i: 6 7 7
  53.  
  54. the third line shows the problem: gnu ever takes the prefix implementation
  55.  
  56.  
  57.  
  58.  
  59.  
  60. 2.) The compiler produces an internal error message, if I try to
  61.     use a template class as a member in another class (and there was no
  62.     prior instance of the same template class).
  63.     The cfront has no problems with it. 
  64.     Is it because its additional instantiation pass?
  65.  
  66. Here is a sample out of a bigger library, where this error occur.
  67. The work around was the external declared dummy of the template.
  68.  
  69.  
  70. -------------------------------cut here-----------------------------
  71. class Iterator;
  72.  
  73. #include <base/generic/tslist.hpp>
  74.  
  75. #ifdef __GNUG__
  76. extern    TSList<Iterator*> temp_dummy_iter_list;
  77.     // this is a hack
  78.     // to avoid internal Compiler error
  79. #endif
  80.  
  81.  
  82. class Collect {
  83. friend class Iterator;
  84.     DECLARE_MEMBERS(Collect);
  85. protected:
  86.     //--- DATA MEMBER ----------------------------------------
  87.     TSList<Iterator*> _active_iter;    // active iterators 
  88.                     // on collection
  89. public:
  90.  
  91. ...
  92.  
  93. };
  94. -------------------------------cut here-----------------------------
  95.  
  96. Without the additional extern deklaration I got the message:
  97.  
  98. collect.cc:577: Internal compiler error.
  99. collect.cc:577: Please report this to `bug-g++@prep.ai.mit.edu'.
  100.  
  101. during compilation of the corresponding source file.
  102. (This is the last line of collect.cc)
  103.  
  104. The proposed hack seems to avoid this problem.
  105.  
  106.  
  107.  
  108. PS: Sorry. My english is terrible. No flames please.
  109. -- 
  110.  
  111.  -------------------------------------------------------------
  112. | Dipl.-Ing. Karsten Pahnke       | Telefon : 0037 672 691167 | 
  113. | Technische Universitaet Ilmenau |           0037 672 691168 |       
  114. | PSF 327, O-6300 Ilmenau         | Telefax : 0037 672 691517 | 
  115. |-------------------------------------------------------------| 
  116. | E-Mail : Pahnke@Inf-Technik.TU-Ilmenau.DE                   |
  117.  -------------------------------------------------------------
  118.  
  119.