Bug Report - Named Return (egcs-2.91)
Philippe Bouchard
boucp00@DMI.USherb.CA
Wed Dec 15 23:29:00 GMT 1999
(I know I have not upgrade yet!.. but just in case...)
The following program:
#include <iostream.h>
template <class TYPE>
struct N {
ÃÂ ÃÂ virtual TYPE & operator += (TYPE &) = 0;
ÃÂ ÃÂ inlineÃÂ TYPE operator + (TYPE &o);
ÃÂ ÃÂ };
// Non-Working Version:
// ----------------
template <class TYPE> TYPE N<TYPE>::operator + (TYPE &o)
return r(*(TYPE *) this) {
ÃÂ ÃÂ cout<<__PRETTY_FUNCTION__<<endl;
ÃÂ ÃÂ r += o;
ÃÂ ÃÂ }
// Working Version:
// ----------------
//template <class TYPE> TYPE N<TYPE>::operator + (TYPE &o)
{
//ÃÂ ÃÂ cout<<__PRETTY_FUNCTION__<<endl;
//ÃÂ ÃÂ TYPE r(*(TYPE *) this);
//ÃÂ ÃÂ r += o;
//ÃÂ ÃÂ }
struct M : N<M> {
ÃÂ ÃÂ M & operator += (M &) {
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ cout<<__PRETTY_FUNCTION__<<endl;
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ };
void main() {
ÃÂ ÃÂ M m;
ÃÂ ÃÂ m + m;
ÃÂ ÃÂ }
Reports:
namedreturn.cc: In method `struct M N<M>::operator +<M>(struct
M &)':
namedreturn.cc:30:ÃÂ ÃÂ instantiated from here
namedreturn.cc:12: no match for `TYPE & += M &'
PAB
More information about the Gcc-bugs
mailing list