Skip to content

GH58962 regression: Clang rejects &-qualified member function to be overloaded with const-qualified with mutual exclusive constraints #120812

Open
@zhihaoy

Description

@zhihaoy

Worked in: Clang 17
Stop working since: Clang 18

Symptom

Clang 18.1.0 and trunk reject the following program in -std=c++20, but accept it in -std=c++23. Clang 17.1.0 accepts it in -std=c++20, so does GCC and MSVC.

namespace GH58962_alt
{

template <unsigned R> struct type
{
    void func() const
        requires(R == 0);
    void func() &
        requires(R == 1);
};

template <typename T>
concept test = requires(T v) { decltype(v)(v).func(); };

static_assert(test<type<0> &>);
static_assert(test<type<0> &&>);
static_assert(test<type<1> &>);
static_assert(not test<type<1> &&>);

static_assert(test<type<0> const &>);
static_assert(test<type<0> const &&>);
static_assert(not test<type<1> const &>);
static_assert(not test<type<1> const &&>);

} // namespace GH58962_alt

https://godbolt.org/z/vY63TE43K

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions