concurrencpp
concurrencpp copied to clipboard
Compilation errors with Clang 14
I tried to compile the develop branch of this library with Clang 14 as it ships with Ubuntu 22.04 but ran into the following compilation errors:
In file included from /home/chris/.conan/data/concurrencpp/0.1.4/_/_/build/7e645c2460c8f2c2ceae31d40d031404517400b0/source_subfolder/source/timers/timer.cpp:7:
/home/chris/.conan/data/concurrencpp/0.1.4/_/_/build/7e645c2460c8f2c2ceae31d40d031404517400b0/source_subfolder/include/concurrencpp/executors/executor.h:66:29: error: no viable conversion from 'std::vector<task>' to 'std::span<task>'
std::span<task> span = tasks;
^ ~~~~~
/usr/lib/llvm-14/bin/../include/c++/v1/span:401:15: note: candidate constructor not viable: no known conversion from 'std::vector<task>' to 'const std::span<concurrencpp::task, 18446744073709551615> &' for 1st argument
constexpr span (const span&) noexcept = default;
^
/usr/lib/llvm-14/bin/../include/c++/v1/span:425:15: note: candidate template ignored: could not match 'type_identity_t<std::span<concurrencpp::task, 18446744073709551615>::element_type>[_Sz]' (aka 'concurrencpp::task[_Sz]') against 'std::vector<task>'
constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
^
/usr/lib/llvm-14/bin/../include/c++/v1/span:430:15: note: candidate template ignored: could not match 'array' against 'vector'
constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
^
/usr/lib/llvm-14/bin/../include/c++/v1/span:435:15: note: candidate template ignored: could not match 'array' against 'vector'
constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
^
/usr/lib/llvm-14/bin/../include/c++/v1/span:445:19: note: candidate template ignored: could not match 'span' against 'vector'
constexpr span(const span<_OtherElementType, _OtherExtent>& __other,
There's a couple more of these in the tests which are also related to conversion of std::span and std::vector. I am not sure why compilation succeeds with earlier versions of Clang. It seems the compiler is not considering overload 7 of the span constructor here.
I think it's related to bugs in libc++, here is a repo: https://godbolt.org/z/sjrf7TePo. The errors only occur for libc++, not libstdc++.
For Clang 13 and earlier, the span constructor taking iterators seems not supported, while for Clang 14 the constructor taking a range does not work. The only constructor overload that appears to work across all versions is the one taking a pointer and size.