home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!inf-technik.tu-ilmenau.DE!Karsten.Pahnke
- From: Karsten.Pahnke@inf-technik.tu-ilmenau.DE (Karsten Pahnke)
- Newsgroups: gnu.g++.bug
- Subject: operator++
- Date: 21 Jan 1993 18:07:53 -0500
- Organization: GNUs Not Usenet
- Lines: 106
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <9301211109.AA27664@pegasus.inf-technik.tu-ilmenau.de>
-
- Hallo gnu--developers,
-
- I have two problems with the g++2.3.3:
-
- 1.) The compiler does not distinct pre- and postfix versions
- of increment and decrement operators.
- I think this is a difference to the ARM.
-
- Here a small example:
- ----------------cut here--------------------------------------------------
- #include <iostream.h>
-
- class Integer {
- private:
- int _val;
- public:
- Integer(int val = 0) {_val = val;}
-
- int operator++() { _val++; return _val; }
- int operator++(int) { int temp = _val; _val++; return temp; }
- operator int() const { return _val; }
- };
-
- main()
- {
- Integer i(5);
- cout << "i : " << i << endl;
- cout << "i++: 5 5 6 ok" << endl;
- cout << "i++: " << i << ' ' << i++ << ' ' << i << endl;
- cout << "++i: 6 7 7 ok" << endl;
- cout << "++i: " << i << ' ' << ++i << ' ' << i << endl;
- }
-
- ----------------cut here--------------------------------------------------
- the executable produces the following output:
- i : 5
- i++: 5 5 6 ok
- i++: 5 6 6
- ++i: 6 7 7 ok
- ++i: 6 7 7
-
- the third line shows the problem: gnu ever takes the prefix implementation
-
-
-
-
-
- 2.) The compiler produces an internal error message, if I try to
- use a template class as a member in another class (and there was no
- prior instance of the same template class).
- The cfront has no problems with it.
- Is it because its additional instantiation pass?
-
- Here is a sample out of a bigger library, where this error occur.
- The work around was the external declared dummy of the template.
-
-
- -------------------------------cut here-----------------------------
- class Iterator;
-
- #include <base/generic/tslist.hpp>
-
- #ifdef __GNUG__
- extern TSList<Iterator*> temp_dummy_iter_list;
- // this is a hack
- // to avoid internal Compiler error
- #endif
-
-
- class Collect {
- friend class Iterator;
- DECLARE_MEMBERS(Collect);
- protected:
- //--- DATA MEMBER ----------------------------------------
- TSList<Iterator*> _active_iter; // active iterators
- // on collection
- public:
-
- ...
-
- };
- -------------------------------cut here-----------------------------
-
- Without the additional extern deklaration I got the message:
-
- collect.cc:577: Internal compiler error.
- collect.cc:577: Please report this to `bug-g++@prep.ai.mit.edu'.
-
- during compilation of the corresponding source file.
- (This is the last line of collect.cc)
-
- The proposed hack seems to avoid this problem.
-
-
-
- PS: Sorry. My english is terrible. No flames please.
- --
-
- -------------------------------------------------------------
- | Dipl.-Ing. Karsten Pahnke | Telefon : 0037 672 691167 |
- | Technische Universitaet Ilmenau | 0037 672 691168 |
- | PSF 327, O-6300 Ilmenau | Telefax : 0037 672 691517 |
- |-------------------------------------------------------------|
- | E-Mail : Pahnke@Inf-Technik.TU-Ilmenau.DE |
- -------------------------------------------------------------
-
-