'Class with constructor template requiring copyable argument is not copyable by itself

In the following program struct A has a constructor template A(T) requiring that the type T be copy-constructible. At the same time A itself must have implicitly defined copy-constructor:

#include <type_traits>

struct A {
    template <class T>
    A(T) requires(std::is_copy_constructible_v<T>) {}
};
static_assert(std::is_copy_constructible_v<A>);

and the last static_assert(std::is_copy_constructible_v<A>) passes in GCC and MSVC, but Clang rejects it, complaining:

error: substitution into constraint expression resulted in a non-constant expression
    A(T) requires(std::is_copy_constructible_v<T>) {}
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:971:30: note: while checking constraint satisfaction for template 'A<A>' required here
    : public __bool_constant<__is_constructible(_Tp, _Args...)>
                             ^~~~~~~~~~~~~~~~~~
...

Demo: https://gcc.godbolt.org/z/shKe7W1jr

Is it just a Clang bug?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source