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