hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Apple Clang 13 doesn't support `std::copy_constructible` concept used in `cpp2util.h`

bluetarpmedia opened this issue · comments

Describe the bug
The following code in cpp2util.h (lines 367-371) doesn't compile in Apple Clang 13:

template <typename T>
    requires (std::copy_constructible<std::remove_cvref_t<T>>)
auto move(T&& t) -> decltype(auto) {
    return std::move(t);
}

To Reproduce
See a recent build on GitHub Actions
Expand the Build section and scroll to the top

source/../include/cpp2util.h:368:20: error: no template named 'copy_constructible' in namespace 'std'; did you mean 'is_copy_constructible'?
    requires (std::copy_constructible<std::remove_cvref_t<T>>)
              ~~~~~^~~~~~~~~~~~~~~~~~
                   is_copy_constructible

Apple Clang 13 is based off LLVM Clang 12.

Repro on Godbolt for Clang 12.

To be more specific, the problem isn't with the compiler itself but with the version of the standard library that it ships with.

In Xcode, by default Apple Clang links with libc++. And the version of libc++ that ships with Xcode 13 (Apple Clang 13) doesn't have copy_constructible.

Can repro this on Compiler Explorer:

  • Works: Clang 12 with libstdc++
  • Fails: Clang 12 with libc++ [This is the closest equivalent to Xcode 13]
  • Works: Clang 13 with libc++

Thanks! It worked on the compilers/libs I'm testing with locally so I thought, hey, it's 2024, why not use a concept? Turns out there was an answer to that question! 😆

Changing to is_copy_constructible_v and running regression...