Internal Compiler Error with cast from void* to function pointer

Stephan A. Fiedler saffron@rincon.com
Thu Jan 8 15:31:00 GMT 1998


Below please find a test case for this problem.  I now know that such a
cast is illegal (in fact, in some cases (see comment in test case), EGCS
will even tell me it is! :), but the compiler asked me to submit a bug
report, so I am.

g++ -v reports:

gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)



The file below exhibits the problem:

--- begin included text --- 

// If you comment out this first set of definitions, and uncomment the
// second, then the compiler will not die (but instead produce a
// helpful diagnostic).

#define TYPE const char* product
#define ARG "some product"

/*
#define TYPE
#define ARG2
*/

template <class T>
class FactoryT {

  public:

    T* manufacture (TYPE);


};



template <class T>
T* FactoryT<T>::manufacture (TYPE)
{
  void* vp;
  
  T* (*instantiator) () =
    reinterpret_cast<T* (*) ()>(vp);

  return (*instantiator)();
}



int main (int, char**)
{
  FactoryT<int> t;

  t.manufacture(ARG);

  return 0;
}

--- end included text ---



More information about the Gcc-bugs mailing list