hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.24k stars 224 forks source link

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

Closed bluetarpmedia closed 3 months ago

bluetarpmedia commented 3 months ago

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.

bluetarpmedia commented 3 months ago

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:

hsutter commented 3 months ago

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...