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

           Summary: [C++0x] SFINAE does not handle comparisons between
                    incompatible pointer types well
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: gintensub...@gmail.com


template< class T >
T&& declval();

template< class T, class U >
struct is_equality_comparable
{
  typedef char one_;
  typedef struct { char a[2]; } two_;

  template< class T_, class U_ >
  static decltype( declval<T_>() == declval<U_>(), one_() ) test_( int );

  template< class T_, class U_ >
  static two_ test_( ... );

  static const bool value = ( sizeof( test_<T, U>( 0 ) ) == 1 );

};

int main()
{
  static_assert( is_equality_comparable<int*, void*>::value, "OK." );
  static_assert( is_equality_comparable<int*, double*>::value, "shall be
false." );
}


-------------------

This code should be ill-formed, but gcc (-std=c++0x) accepts it, on all of
following versions:

4.5.1
4.6.0
4.6.1-20110415
4.7.0-20110416

Reply via email to