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



             Bug #: 56913

           Summary: [C++11] SFINAE for ill-formed pointer-to-member

                    operators with incompatible ref-qualifiers

    Classification: Unclassified

           Product: gcc

           Version: 4.9.0

            Status: UNCONFIRMED

          Severity: minor

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ai.az...@gmail.com





Created attachment 29851

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29851

Output of -v option and preprocessed source



GCC 4.8.1 20130404 and 4.9.0 20130407 reject the following well-formed code;



//-----------------------------------------------------------

template<typename T>

T &&declval();



template<typename T, typename U,

         typename = decltype((declval<T>().*declval<U>())())>

constexpr bool test(int)

{

  return true;

}



template<typename T, typename U>

constexpr bool test(...)

{

  return false;

}



struct S

{};



static_assert(!test<S, void (S::*)() &>(0), "");

static_assert(test<S, void (S::*)() &&>(0), "");

static_assert(test<S &, void (S::*)() &>(0), "");

static_assert(!test<S &, void (S::*)() &&>(0), "");

//-----------------------------------------------------------



For the above code, GCC 4.9.0 20130407 complains as follows;



main.cpp:5:43: error: pointer-to-member-function type 'void (S::*)() &'

requires an lvalue

          typename = decltype((declval<T>().*declval<U>())())>

                                           ^

main.cpp:20:1: error: static assertion failed: 

 static_assert(!test<S, void (S::*)() &>(0), "");

 ^

main.cpp:5:43: error: pointer-to-member-function type 'void (S::*)() &&'

requires an rvalue

          typename = decltype((declval<T>().*declval<U>())())>

                                           ^

main.cpp:23:1: error: static assertion failed: 

 static_assert(!test<S &, void (S::*)() &&>(0), "");

 ^



SFINAE does not seem to be applied to ill-formed pointer-to-member operators

(as per N3485 [expr.mptr.oper]/6) instantiated in the first and fourth

static_asserts, and they result in hard errors.

Reply via email to