Topic: VC6 bug (?) address of template function member
Author: "Alfred Kellner" <alfkellner@magnet.at>
Date: 1999/02/07 Raw View
Dan Vasaru <dvasaru@idi.ntnu.no> wrote
[...]
> I've been trying all day now (without success) to take the address of a
> template function member in VC 6.0 SP2. Am I missing something on the syntax
> or is this a bug in VC 6 ? The error message I'm getting is really
> informative:
[...]
> :\test.cpp(29) : fatal error C1001: INTERNAL COMPILER ERROR
> (compiler file 'msc1.cpp', line 1786)
[...]
> class A
> {
> public:
> typedef void (A::*afn)(void);
> static afn compute_table[3];
> template<class T> void myfn(T*data) { *data += 10;}
> };
[...]
> template void A::myfn<char>(char*); // this gives internal compiler error
[...]
> A::afn A::compute_table[]=
> {
> &A::myfn<char>, // INTERNAL COMPILER ERROR
> A::myfn<float>, // INTERNAL COMPILER ERROR
> &A::myfn<double>
> };
[...]
don't know which VC-6.0-service-pack is equivalent to egcs-1.1.1
--ALfred
<code>
class A {
public:
typedef void ( A::* A_MFP_void )(void);
static A_MFP_void aMfp[ 3 ];
// Type 0
template<class T> void myfn( void ) {}
typedef void ( A::* A_MFP_float )(float *);
static A_MFP_float aMfpFloat[ 3 ];
// Type 1 T*
template<class T> void myfn( T * ) {}
};
void f( A * t ) {
// Type 1
t->myfn( (char*)0 ); // void A::myfn<T>(char*)
t->myfn( (float*)0 ); // void A::myfn<T>(float*)
t->myfn( (double*)0 ); // void A::myfn<T>(double*)
}
void ( A::* A::aMfp[3] )(void)
= {
// Type 0
& A::template myfn<char>, // void (A::*)(void)
& A::template myfn<float>, // void (A::*)(void)
& A::template myfn<double>, // void (A::*)(void)
};
void ( A::* A::aMfpFloat[3] )(float*)
= {
// Type 1 float*
& A::template myfn<char>, // void (A::*)(float *)
& A::template myfn<float>, // void (A::*)(float *)
& A::template myfn<double>, // void (A::*)(float *)
};
void ( A::* mfpChr )(char* ) = & A::template myfn<char>;
void ( A::* mfpFlt )(float* ) = & A::template myfn<char>;
void ( A::* mfpDbl )(double*) = & A::template myfn<char>;
// array of : void A::myfn<char>( ??? )
// warning
void ( A::* aMfpXXX[3] )( ... ) // ANSI C++ prohibits conversion
= {
mfpChr, // Type 1 char*
mfpFlt, // Type 1 float*
mfpDbl, // Type 1 double*
};
</code>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Dan Vasaru" <dvasaru@idi.ntnu.no>
Date: 1999/02/03 Raw View
Hi,
I've been trying all day now (without success) to take the address of a
template function member in VC 6.0 SP2. Am I missing something on the syntax
or is this a bug in VC 6 ? The error message I'm getting is really
informative:
/////////////////////////
:\test.cpp(29) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
////////////////////////
Here's the code
/////////////////////////////////////////////////
class A
{
public:
typedef void (A::*afn)(void);
static afn compute_table[3];
template<class T> void myfn(T*data) { *data += 10;}
};
fn()
{
A*t=0;
t->myfn((char*)0); // FINE
t->myfn((float*)0); // FINE
t->myfn((double*)0); // FINE
}
template void A::myfn<char>(char*); // this gives internal compiler error
template void A::myfn(char*); // this compiles though I don't know what it
really means
A::afn A::compute_table[]=
{
&A::myfn<char>, // INTERNAL COMPILER ERROR
A::myfn<float>, // INTERNAL COMPILER ERROR
&A::myfn<double>
};
Tnx,
Dan
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]