$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Doug Gregor (dgregor_at_[hidden])
Date: 2007-06-27 09:13:43
On Jun 26, 2007, at 5:05 PM, gast128 wrote:
> Since no one react, I tried to reverse engineer Boost.Function and  
> pin down
> the problem:
>
> template <typename R, typename Arg1>
> struct Functor
> {
>     template <typename F>
>     Functor(F f, int i = 0)
>     : m_pf(0)
>     {
>         m_pf = reinterpret_cast<Pf>(f);
>     }
>
>     template <typename T>
>     R Invoke(T t)
>     {
>         typedef R (*Pf1)(Arg1);
>         return (*(Pf1)m_pf)(t);
>     }
>
>     typedef void (*Pf)(void);
>     Pf  m_pf;
> };
>
> template <typename T>
> bool func_template(T* p)
> {
>     return p != 0;
> }
>
> void TestBugFunctor()
> {
>     Functor<bool, int*> fc2 = &func_template<int>;
>     fc2.Invoke((int*)0);  //crash
> }
>
>
> The trick with the extra dummy constructor argument is copied form  
> boost
> function header files. Without it one gets an ICE, but with it,  
> VStudio 2003
> sp1 generates a suspectable call.
Oh, that's bad. I don't have this compiler on hand to work with... if  
someone has a workaround, I would gladly apply it to Boost.Function.
        - Doug