|
Archives
D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows
digitalmars.empire
digitalmars.DMDScript
|
c++ - Internal error: exp2 121
↑ ↓ ← → Iliya Peregoudov <iliyap mail.ru> writes:
/* matrix.cpp */
#include <iostream.h>
template <class T, int n, int m>
class Matrix {
T v[n][m];
public:
Matrix() { cout << "Matrix<T,n,m>" << endl; };
template <class TT, int nn, int mm>
friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const
Matrix<TT,nn,mm> &);
};
template <class T, int n, int m>
Matrix<T,n,m> operator+(const Matrix<T,n,m> &x, const Matrix<T,n,m> &y)
{
cout << "operator+<T,n,m>" << endl;
Matrix<T,n,m> r;
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
r.v[i][j] = x.v[i][j] + y.v[i][j];
return r;
}
template <class T>
class Matrix<T, 3, 3> {
T v[3][3];
public:
Matrix() { cout << "Matrix<T,3,3>" << endl; };
template <class TT>
friend Matrix<TT,3,3> operator+(const Matrix<TT,3,3> &, const
Matrix<TT,3,3> &);
};
template <class T>
Matrix<T,3,3> operator+(const Matrix<T,3,3> &x, const Matrix<T,3,3> &y)
{
cout << "operator+<T,3,3>" << endl;
Matrix<T,3,3> r;
r.v[0][0] = x.v[0][0] + y.v[0][0];
r.v[0][1] = x.v[0][1] + y.v[0][1];
r.v[0][2] = x.v[0][2] + y.v[0][2];
r.v[1][0] = x.v[1][0] + y.v[1][0];
r.v[1][1] = x.v[1][1] + y.v[1][1];
r.v[1][2] = x.v[1][2] + y.v[1][2];
r.v[2][0] = x.v[2][0] + y.v[2][0];
r.v[2][1] = x.v[2][1] + y.v[2][1];
r.v[2][2] = x.v[2][2] + y.v[2][2];
return r;
}
int main(void)
{
Matrix<int,3,3> m;
m + m;
return 0;
}
While compiled with dmc 8.29 (STLport STL not installed):
m + m;
^
matrix2.cpp(57) : Error: ambiguous reference to symbol
Had: operator +(const Matrix<>&,const Matrix<>&)
and: operator +(const Matrix<>&,const Matrix<>&)
Internal error: exp2 121
--- errorlevel 1
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
I'll have a look at it. Thanks. -Walter
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
This is fixed now in the beta www.digitalmars.com/download/freecompiler.html
But, it will still be necessary to make sure the parameter spelling in the
template-parameter-list in the friend declaration matches the corresponding
definition.
-Walter
"Iliya Peregoudov" <iliyap mail.ru> wrote in message
news:3D899630.3523 mail.ru...
/* matrix.cpp */
#include <iostream.h>
template <class T, int n, int m>
class Matrix {
T v[n][m];
public:
Matrix() { cout << "Matrix<T,n,m>" << endl; };
template <class TT, int nn, int mm>
friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const
Matrix<TT,nn,mm> &);
};
template <class T, int n, int m>
Matrix<T,n,m> operator+(const Matrix<T,n,m> &x, const Matrix<T,n,m> &y)
{
cout << "operator+<T,n,m>" << endl;
Matrix<T,n,m> r;
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
r.v[i][j] = x.v[i][j] + y.v[i][j];
return r;
}
template <class T>
class Matrix<T, 3, 3> {
T v[3][3];
public:
Matrix() { cout << "Matrix<T,3,3>" << endl; };
template <class TT>
friend Matrix<TT,3,3> operator+(const Matrix<TT,3,3> &, const
Matrix<TT,3,3> &);
};
template <class T>
Matrix<T,3,3> operator+(const Matrix<T,3,3> &x, const Matrix<T,3,3> &y)
{
cout << "operator+<T,3,3>" << endl;
Matrix<T,3,3> r;
r.v[0][0] = x.v[0][0] + y.v[0][0];
r.v[0][1] = x.v[0][1] + y.v[0][1];
r.v[0][2] = x.v[0][2] + y.v[0][2];
r.v[1][0] = x.v[1][0] + y.v[1][0];
r.v[1][1] = x.v[1][1] + y.v[1][1];
r.v[1][2] = x.v[1][2] + y.v[1][2];
r.v[2][0] = x.v[2][0] + y.v[2][0];
r.v[2][1] = x.v[2][1] + y.v[2][1];
r.v[2][2] = x.v[2][2] + y.v[2][2];
return r;
}
int main(void)
{
Matrix<int,3,3> m;
m + m;
return 0;
}
While compiled with dmc 8.29 (STLport STL not installed):
m + m;
^
matrix2.cpp(57) : Error: ambiguous reference to symbol
Had: operator +(const Matrix<>&,const Matrix<>&)
and: operator +(const Matrix<>&,const Matrix<>&)
Internal error: exp2 121
--- errorlevel 1
↑ ↓ ← → Iliya Peregoudov <iliyap mail.ru> writes:
Walter wrote:
This is fixed now in the beta www.digitalmars.com/download/freecompiler.html
But, it will still be necessary to make sure the parameter spelling in the
template-parameter-list in the friend declaration matches the corresponding
definition.
This beta (scppn.exe, 09/20/2002) compiles previous code but crashes
with the following code that doesn't use specializations at all!
/* matrix.cpp */
#include <iostream.h>
template <class T, int n, int m>
class Matrix {
T v[n][m];
public:
Matrix() { cout << "Matrix<T,n,m>" << endl; };
template <class TT, int nn, int mm>
friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const
Matrix<TT,nn,mm> &);
};
template <class TT, int nn, int mm>
Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &x, const
Matrix<TT,nn,mm> &y)
{
cout << "operator+<T,n,m>" << endl;
Matrix<TT,nn,mm> r;
for (int i = 0; i < nn; ++i)
for (int j = 0; j < mm; ++j)
r.v[i][j] = x.v[i][j] + y.v[i][j];
return r;
}
int main(void)
{
Matrix<int,3,3> m;
m + m;
return 0;
}
dmc -A matrix3.cpp
m + m;
^
matrix3.cpp(27) : Error: template-argument 'mm' has no value in template
function specialization
matrix3.cpp(14) : Error: '(' expected following simple type name
--- errorlevel 1
And compiler pops up the Windows fatal error panel:
SCPPN caused an invalid page fault in
module SCPPN.EXE at 015f:0042b022.
Registers:
EAX=008a15c4 CS=015f EIP=0042b022 EFLGS=00010203
EBX=008a15c4 SS=0167 ESP=006fefc8 EBP=00000000
ECX=00000000 DS=0167 ESI=006ff3a4 FS=35b7
EDX=008a0104 ES=0167 EDI=00000000 GS=34f6
Bytes at CS:EIP:
81 49 28 60 08 00 00 83 bc 24 dc 03 00 00 00 74
Stack dump:
00000000 008a0248 0089ddfe 00000007 008a00d4 0071db88 00000000
008a0104 0089de32 00890078 00000019 00414010 00000019 0089acfc
00000000 00000001
↑ ↓ ← → Iliya Peregoudov <iliyap mail.ru> writes:
Iliya Peregoudov wrote:
This beta (scppn.exe, 09/20/2002) compiles previous code but crashes
with the following code that doesn't use specializations at all!
And the original 8.29 (scppn.exe, 07/31/2002) also crashes on the same
file:
SCPPN caused an invalid page fault in
module SCPPN.EXE at 015f:0042aca2.
Registers:
EAX=008a0de4 CS=015f EIP=0042aca2 EFLGS=00010203
EBX=008a0de4 SS=0167 ESP=006fefd0 EBP=00000000
ECX=00000000 DS=0167 ESI=006ff3ac FS=21ff
EDX=0089ebfa ES=0167 EDI=00000000 GS=2226
Bytes at CS:EIP:
81 49 28 60 08 00 00 83 bc 24 dc 03 00 00 00 74
Stack dump:
00000000 0089ed1e 0089d7fe 0089ef42 0089ebd2 026662b0 00000000
0089ebfa 0089d882 00000078 0089a72c 0089d882 00000019 00413f1c
00000019 0089a72c
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
Ok, I'll check it out.
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
Ok, I posted the fix for this. -Walter
"Iliya Peregoudov" <iliyap mail.ru> wrote in message
news:3D8C47BA.1010805 mail.ru...
Walter wrote:
This is fixed now in the beta
But, it will still be necessary to make sure the parameter spelling in
template-parameter-list in the friend declaration matches the
definition.
This beta (scppn.exe, 09/20/2002) compiles previous code but crashes
with the following code that doesn't use specializations at all!
/* matrix.cpp */
#include <iostream.h>
template <class T, int n, int m>
class Matrix {
T v[n][m];
public:
Matrix() { cout << "Matrix<T,n,m>" << endl; };
template <class TT, int nn, int mm>
friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const
Matrix<TT,nn,mm> &);
};
template <class TT, int nn, int mm>
Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &x, const
Matrix<TT,nn,mm> &y)
{
cout << "operator+<T,n,m>" << endl;
Matrix<TT,nn,mm> r;
for (int i = 0; i < nn; ++i)
for (int j = 0; j < mm; ++j)
r.v[i][j] = x.v[i][j] + y.v[i][j];
return r;
}
int main(void)
{
Matrix<int,3,3> m;
m + m;
return 0;
}
dmc -A matrix3.cpp
m + m;
^
matrix3.cpp(27) : Error: template-argument 'mm' has no value in template
function specialization
matrix3.cpp(14) : Error: '(' expected following simple type name
--- errorlevel 1
And compiler pops up the Windows fatal error panel:
SCPPN caused an invalid page fault in
module SCPPN.EXE at 015f:0042b022.
Registers:
EAX=008a15c4 CS=015f EIP=0042b022 EFLGS=00010203
EBX=008a15c4 SS=0167 ESP=006fefc8 EBP=00000000
ECX=00000000 DS=0167 ESI=006ff3a4 FS=35b7
EDX=008a0104 ES=0167 EDI=00000000 GS=34f6
Bytes at CS:EIP:
81 49 28 60 08 00 00 83 bc 24 dc 03 00 00 00 74
Stack dump:
00000000 008a0248 0089ddfe 00000007 008a00d4 0071db88 00000000
008a0104 0089de32 00890078 00000019 00414010 00000019 0089acfc
00000000 00000001
↑ ↓ ← → Iliya Peregoudov <iliyap mail.ru> writes:
Walter wrote:
Ok, I posted the fix for this. -Walter
Works fine, thanks. Great!
|
|