Skip to content

[clang] Incorrect "error: copy constructor must pass its first argument by reference" with unsatisfied constraint #158475

@avikivity

Description

@avikivity
#include <concepts>

template <typename T>
struct a {
    T v;
    a(a<int> x) requires (!std::same_as<T, int>) : v(x.v) {} 
};

yields (clang 21.1.0)

<source>:7:14: error: copy constructor must pass its first argument by reference

However, the constructor should be ignored since the constraint is not satisfied. It is meant as a converting constructor when T != int, so requiring it to pass the first argument by reference is not sensible.

clang 20.1.8 works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"waiting-for-wg21Blocked on C++ Standards Committee

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions