Title: ICE on VC7.0 (and VC6) attempting to resolve member function pointer
for a templated member function specialized by pointer-to-member-function
type (in case Newsgroups truncates it)
I have a piece of code that is supposed to be representative of a new
function-dispatching mechanism we're trying to implement. Here it is:
<CODE>
struct DispatchParameters {};
struct DispatchReturns {};
template<class Derived> struct Dispatcher
{
typedef void (Derived::*NOPARAMFUNC)();
typedef void (Derived::*LONGFUNC)(long);
typedef void (Derived::*DISPFUNC)(NOPARAMFUNC, const DispatchParameters&,
DispatchReturns&);
template<NOPARAMFUNC>
void dispatch(NOPARAMFUNC pFunc, const DispatchParameters&,
DispatchReturns&)
{
((static_cast<Derived*>(this))->*pFunc)();
}
template<LONGFUNC>
void dispatch(LONGFUNC pFunc, const DispatchParameters&, DispatchReturns& )
{
((static_cast<Derived*>(this))->*pFunc)(1L);
}
};
struct Sink: Dispatcher<Sink>
{
void P1();
void P2(long);
const DISPFUNC f1, f2;
Sink(): f1(reinterpret_cast<DISPFUNC>(&Sink::dispatch<&Sink::P1>)),
f2(reinterpret_cast<DISPFUNC>(&Sink::dispatch<&Sink::P2>)) {}
};
int main()
{
Sink sink;
return 0;
}
</CODE>
The idea is that in real code f1 and f2 will be replaced by entries in a
map, and macros uncannily similar to ATL's SINK_MAP_ENTRY etc will be used
to specify the map. The idea of the template parameters on the overloaded
dispatch functions in Dispatcher is to allow them to be disambiguated
depending on the function signature. I realise doing reinterpret_cast on a
member function pointer is not ideal, but I believe it is going to be safe
in the way I'm actually going to use it.
On both VC6 and VC7.0, an ICE occurs. I'm hardly surprised on VC6, but I had
hoped VC7 would be able to deal with this. I don't have VC7.1, Whidbey etc
so if someone here could try it out for me on that, that would be great. The
code above compiles without error with Comeau's online compiler.
(I don't need a solution to this problem. I am raising it as a conformance
issue only.)
Visual Studio 6.0, SP5 says:
EventSinkSandpit.cpp
c:\users\strew\scratchpad\eventsinksandpit\eventsinksandpit.cpp(35) : fatal
error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Visual Studio 7.0 (Microsoft Visual C++ .NET 55603-652-0000007-18379)
says:
Compiling...
EventSinkSandpit.cpp
c:\Documents and Settings\strew\My Documents\Visual Studio
Projects\EventSinkSandpit\EventSinkSandpit.cpp(31) : fatal error C1001:
INTERNAL COMPILER ERROR
(compiler file
'f:\vs70builds\9466\vc\Compiler\CxxFE\sl\p1\Cxx\grammar.y', line 9326)
Comeau (www.comeaucomputing.com/tryitout/) -- No errors.