This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15480] ICE with sizeof(T().f()) as template parameter in function resolution
- From: "gianni at mariani dot ws" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 May 2004 06:26:05 -0000
- Subject: [Bug c++/15480] ICE with sizeof(T().f()) as template parameter in function resolution
- References: <20040516212738.15480.gianni@mariani.ws>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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