This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/570: Internal error 71 with parametrised operator template



>Number:         570
>Category:       c++
>Synopsis:       Internal error 71 with parametrised operator template
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 26 09:26:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Christian Schüler
>Release:        gcc 2.95.2 release 19991024
>Organization:
>Environment:
DJGPP under DOS and also MinGW32 under Windows
>Description:
I tried to implement parametrised operator templates for a vector-math library to have the compiler generate calculations row by row instead of vector by vector, in similarity of "dense arrays".

My intention was, that the code

   Vector3d a, b, c, d;
   a = b + c + d;

translates to

   a[0] = b[0] + c[0] + d[0];
   a[1] = b[1] + c[1] + d[1];
   a[2] = b[2] + c[2] + d[2];

GCC 2.95.2, that is the engine of both DJGPP and MinGW32 that I have on my computer, reports "Internal Error 71" at line 10 of the code listed below:
>How-To-Repeat:

template< typename TYPEA, typename TYPEB, const TYPEA &A, const TYPEB &B >
struct OP_plus {
   float operator[]( int i ) const { return A[i] + B[i]; }
};

template< typename TYPEA, typename TYPEB >
inline OP_plus< TYPEA, TYPEB, A, B >
operator +( const TYPEA &A, const TYPEB &B )
{ return OP_plus< TYPEA, TYPEB, A, B >(); }


struct Vector3D
{
   float x[3];
   float operator[]( int i ) const { return x[i]; }

   template< typename TYPE >
   Vector3D &operator =( const TYPE &other ) {
      x[0] = other[0];
      x[1] = other[1];
      x[2] = other[2];
      return *this;
   }
};

Vector3D A, B, C, D;

int main()
{
   A = B + C + D;
   return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]