Skip to content

[Clang] Clang incorrectly calculates constraints involving private members and multiple nested classes of the same name #198716

@frederick-vs-ja

Description

@frederick-vs-ja

Since Clang 22, Clang starts rejecting the following code snippet (Godbolt link), which is perhaps incorrect.

Note that Clang behaves as expected if two nested classes are of different names.

struct A {
  class Nested { // N.B. Both nested classes have the same name.
  private:
    static void test_function();
  };
};

template <class T>
concept has_member_test_function = requires {
  T::test_function();
};

static_assert(!has_member_test_function<A::Nested>);

struct B {
  struct Nested { // N.B. Both nested classes have the same name.
    template <class T>
      requires has_member_test_function<T>
    Nested(const T&);
  };
};

template <class From, class To>
concept quick_convertible_to = requires(From&& t, void (&fun)(To)) {
  fun(static_cast<From&&>(t));
};

static_assert(!quick_convertible_to<A::Nested, B::Nested>);

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsdiverges-from:edgDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueregression:22Regression in 22 release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions