Skip to content

[clang] Concept can access a private type in a dependent template #93788

@sigasigasiga

Description

@sigasigasiga

This code compiles just fine although it shouldn't

#include <concepts>

template<typename T>
class trait
{
    using type = int; // note that the type is private
};

template<typename T>
concept has_field = requires(T t) {
    { t.field } -> std::convertible_to<typename trait<T>::type>;
};

struct foo
{
    int field;
};

static_assert(has_field<foo>);

https://godbolt.org/z/WKzo7E7cK

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions