Code that is problematic follows.
>>> snip
#include <string>

template<typename T>
inline void 
do_call(int (*fn)(T),
        const char* msg,
        T t1)
{
  int err;
  if ((err = fn(t1)) < 0){
    throw std::string(msg);
  }
}

int
fn(int* a)
{
  return (a ?   1 :  -1);
}

int main(int argc ,char** argv)
{
  int j;
  do_call(fn, "hello", &j);
  do_call(fn, "hello", 0);
  do_call(fn, "hello", static_cast<int*>(0));           
}
>>> end snip

The problem seems to be that recent gcc's dont compile the second do_call 
because
they interpret 0 as being of type int. I have no idea whether c++ should be able
to do this, but it seems to me that gcc could find the right code to generate.
static_casting to int of course solves the problem.
Immanuel

***************************************************************************
I can, I can't.
Tubbs Tattsyrup

--
Immanuel Litzroth
Software Development Engineer
Enfocus Software
Antwerpsesteenweg 41-45
9000 Gent
Belgium
Voice: +32 9 269 23 90
Fax : +32 9 269 16 91
Email: [EMAIL PROTECTED]
web : www.enfocus.be
***************************************************************************

Reply via email to