public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15480] New: ICE with sizeof(T().f()) as template parameter in function resolution
@ 2004-05-17  8:02 gianni at mariani dot ws
  2004-05-17  8:10 ` [Bug c++/15480] " gianni at mariani dot ws
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: gianni at mariani dot ws @ 2004-05-17  8:02 UTC (permalink / raw)
  To: gcc-bugs

Below is a template that is supposed to discover wether a type contains a method
 named "Function".

Comeau compiles this fine on Comeau C/C++ 4.3.3, fails on MSC++ 7.1 with what
seems to be the wrong error and ICE's on gcc 3.4.0.



typedef char MPT_False;

struct MPT_True { int m[2]; };


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

template <typename w_D>
struct MPT_Finder_Member
{
    template <typename w_T>
    static MPT_True finder(
        const w_T *,
        typename MPT_IntToType<
            sizeof(w_T().Function())
//          sizeof(static_cast<w_T>(0)->Function()) //fails same way
        >::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();
};

#include <iostream>

int main()
{
    std::cout << MPT_ContainsFuncMember<A>::value << "\n";
    std::cout << MPT_ContainsFuncMember<B>::value << "\n";
}

-- 
           Summary: ICE with sizeof(T().f()) as template parameter in
                    function resolution
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-15480-2828@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2009-04-16 16:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-17  8:02 [Bug c++/15480] New: ICE with sizeof(T().f()) as template parameter in function resolution gianni at mariani dot ws
2004-05-17  8:10 ` [Bug c++/15480] " gianni at mariani dot ws
2004-05-17  8:28 ` pinskia at gcc dot gnu dot org
2004-05-17 14:36 ` giovannibajo at libero dot it
2004-05-17 15:33 ` pinskia at gcc dot gnu dot org
2004-05-17 19:16 ` gianni at mariani dot ws
2004-05-17 19:16 ` bangerth at dealii dot org
2004-05-17 19:32 ` gianni at mariani dot ws
2005-01-06  2:01 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15480-2828@http.gcc.gnu.org/bugzilla/>
2009-04-16 16:35 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).