Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building with clang #12

Closed
abeimler opened this issue Nov 4, 2022 · 2 comments
Closed

Building with clang #12

abeimler opened this issue Nov 4, 2022 · 2 comments

Comments

@abeimler
Copy link

abeimler commented Nov 4, 2022

Hello,
I have some problems using the clang compiler.
A lot of error: missing 'typename' prior to dependent type name-errors in the tests and other errors with ranges like:

[build] /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/ranges_util.h:139:24: error: constraints not satisfied for alias template 'sentinel_t' [with _Range = const std::ranges::ref_view<const xstd::bit_set<0, unsigned char>>]
[build]         && sized_sentinel_for<sentinel_t<const _Derived>,
[build]                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/ranges_base.h:597:12: note: because 'const std::ranges::ref_view<const xstd::bit_set<0, unsigned char>>' does not satisfy 'range'
[build]   template<range _Range>
[build]            ^
[build] /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/ranges_base.h:585:2: note: because 'ranges::begin(__t)' would be invalid: no matching function for call to object of type 'const __cust_access::_Begin'
[build]         ranges::begin(__t);
[build]         ^
bit_set/test/src/set/o2.cpp:9:
bit_set/test/include/set/parallel.hpp:97:41: error: invalid operands to binary expression ('const xstd::bit_set<0, unsigned char>' and '_Partial<std::ranges::views::_Transform, decay_t<(lambda at bit_set/test/include/set/parallel.hpp:95:25)>>' (aka '_Partial<std::ranges::views::_Transform, (lambda at bit_set/test/include/set/parallel.hpp:95:25)>'))
[build]                                         | std::views::transform([=](auto x) { return x - n; })
[build]                                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But also some errors in the library itself (in my other projects):

 warning: invalid case style for template parameter 'expr-type' [readability-identifier-naming]
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:979:13: error: no matching function for call to '__begin' [clang-diagnostic-error]
         = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/ranges_base.h:586:5: note: in instantiation of template type alias '__range_iter_t' requested here
    using iterator_t = std::__detail::__range_iter_t<_Tp>;
    ^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/ranges_util.h:98:43: note: in instantiation of template type alias 'iterator_t' requested here
       data() requires contiguous_iterator<iterator_t<_Derived>>
                                          ^
 /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/ranges_util.h:198:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::subrange<const int *, const int *, std::ranges::subrange_kind::sized>>' requested here
     class subrange : public view_interface<subrange<_It, _Sent, _Kind>>
                             ^
../bit_set.hpp:257:31: note: in instantiation of template class 'std::ranges::subrange<const int *, const int *, std::ranges::subrange_kind::sized>' requested here
                for (auto x : std::ranges::subrange(first, last)) {
                               ^
../bit_set.hpp:70:17: note: in instantiation of function template specialization 'xstd::bit_set<12>::insert<const int *>' requested here
                insert(first, last);
                ^
../bit_set.hpp:75:17: note: in instantiation of function template specialization 'xstd::bit_set<12>::bit_set<const int *>' requested here
                bit_set(ilist.begin(), ilist.end())
                ^

Also some warnings like error: empty expression statement has no effect; remove unnecessary ';' in some for-loops.

Note:
I'm using vcpkg and added the boost libraries for testing in my project...
cmake -B build -S . -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE
https://github.com/abeimler/bit_set/actions/runs/3396267932/jobs/5647138570

Environment:
OS: Linux (Arch Linux 64-Bit)
Compiler: Clang 13

@rhalbersma
Copy link
Owner

rhalbersma commented Dec 23, 2022

Thanks for filing this issue, and sorry for not responding sooner (notifications were off).

Unfortunately, as I mentioned in the README, this library at the moment does not support Clang since that compiler misses too many C++20 features. In particular excessive use typename has been removed from C++20 and that feature is only supported as of Clang 16. But even Clang 16 is not able to successfully compile gcc's 12 libstdc++ ranges library.

The extra ; after braces were a nice catch, not found by gcc, fixed! Thanks for mentioning that.

I am actively monitoring when Clang is getting a gcc 12 level of C++20 support, but at the moment it's just not there yet.

@rhalbersma
Copy link
Owner

I've managed to add Clang support, although at the moment that requires Clang 16-SVN, available in packaged form here: https://apt.llvm.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants