This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15480] ICE with sizeof(T().f()) as template parameter in function resolution


------- Additional Comments From gianni at mariani dot ws  2004-05-17 06:26 -------

I don't know if this is related to this bug but I think this code is also not
correctly parsed by gcc.  Again comeau compiles this fine and MSVC ++ gets all
confused about not being able to deduce func in a similar way to gcc.


typedef char MPT_False;
typedef int MPT_True;


template <unsigned int w_siz>
struct MPT_IntToType
{
    typedef char    type;
};

template <typename T1, typename T2>
int func( T2 ( T1::* )() );

template <typename w_D>
struct MPT_Finder_Member
{

    template <typename w_T>
    static MPT_True finder(
        const w_T *,
        typename MPT_IntToType<
            sizeof( func( & w_T::Function ) )
        >::type * = 0
    );
        
    static MPT_False finder( const w_D * );

};

template <typename w_D >
struct MPT_ContainsFuncMember
{
    struct DerivedClass : w_D
    {
    };

    typedef DerivedClass  * DerivedClassp;

    enum {
        value = (
            sizeof( MPT_Finder_Member<w_D>::finder( DerivedClassp() ) )
            == sizeof( MPT_True )
        )
    };
    
};


struct A
{
};

struct B
{
    int Function();
};

// this works find so func<T1,T2> can be deduced
int x = sizeof( func( &B::Function ) );
int y = MPT_ContainsFuncMember<A>::value;
int z = MPT_ContainsFuncMember<B>::value;



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15480


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]