Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Karsten Pahnke
Thu, 21 Jan 1993 23:07
operator++
Author: Karsten Pahnke
Date: Thu, 21 Jan 1993 23:07
Date: Thu, 21 Jan 1993 23:07
105 lines
3436 bytes
3436 bytes
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 |
-------------------------------------------------------------
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