https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101904

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The validity of this testcase seems closely related to DR1391 which adds an
extra step during template argument deduction for checking the convertibility
of non-dependent function parms/args before instantiating the function
template.

Note that if we turn the two overloads of ZZZ::foo into static member functions
with an explicit 'this' parameter, then both GCC and Clang accept the testcase
as per DR1391:

#include <type_traits>

struct ZZZ
{
    template <typename Func>
    static auto foo(ZZZ*, Func func) -> std::result_of_t<Func(int*)>
    {
        return func(static_cast<int*>(nullptr));
    }

    template <typename Func>
    static auto foo(const ZZZ*, Func func) -> std::result_of_t<Func(const
int*)>
    {
        return func(static_cast<const int*>(nullptr));
    }
};

int main()
{
    const ZZZ zzz;

    ZZZ::foo(&zzz,
        [&](auto* pointer)
        {
            static_assert(std::is_same_v<decltype(pointer), const int*>, "");
        });
}


So it looks like Clang applies DR1391 to the implicit 'this' parameter of
member functions, which seems worthwhile for us to do too (though it's not
strictly required for conformance).  I'm working on a rough patch to that
effect

Reply via email to