Skip to content

[clang][temp.explicit] Explicit template instantiation leads to incorrect checking of constraints #156145

@ddvamp

Description

@ddvamp

Clang trunk x86-64 c++20 (godbolt.org)

template <typename T>
struct S {
  void foo() requires (sizeof(T) == 1); // declaration
};

struct I;

template struct S<I>; // explicit
S<I> s;

struct I {};

template <typename T>
void S<T>::foo() requires (sizeof(T) == 1) { // definition
  static_assert(sizeof(T) == 2);
}

void fn() {
    S<I>{}.foo(); // CE: constraints not satisfied (ill-formed, incomplete type)
}

It looks like the constraints are checked at the point of declaration, not definition. Correct me please if this behavior is determined by the standard

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions