#include <stdexcept>
struct my_error : public std::runtime_error
{
        my_error( std::string const& );
};
template < typename T >
struct wrapper
{
        template < typename R >
        void add_method( R ( T::* )() const );
};
void test()
{
        wrapper< my_error >().add_method( &my_error::what );
}

g++ rejects this code:

error: no matching function for call to &#8216;wrapper<my_error>::add_method(
       const char* (std::runtime_error::*)()const)&#8217;
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         &my_error::what has &std::runtime_error::what type? weird.

btw.
non-templated add_method( char const* ( my_error::* )() const )
works fine, so i suppose it's a bug in c++ frontend.


-- 
           Summary: [reject valid?] mismatch type of virtual method.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net


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

Reply via email to