ned14 / llfio

P1031 low level file i/o and filesystem library for the C++ standard
https://ned14.github.io/llfio/
Other
880 stars 45 forks source link

LLFIO broken with clang-19 #144

Closed jcelerier closed 2 weeks ago

jcelerier commented 3 weeks ago

foo.cpp simply includes llfio.hpp. C++ standard used makes no difference (tried 17 to 26). This is with libstdc++ (Fedora 41):

$ clang++ -c foo.cpp -I /tmp/llfio/include/ -I /tmp/quickcpplib/include/ -I /tmp/outcome/include/
In file included from foo.cpp:1:
In file included from /tmp/llfio/include/llfio.hpp:1:
In file included from /tmp/llfio/include/llfio/llfio.hpp:18:
In file included from /tmp/llfio/include/llfio/v2.0/llfio.hpp:67:
In file included from /tmp/llfio/include/llfio/v2.0/dynamic_thread_pool_group.hpp:526:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp:27:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/../../file_handle.hpp:28:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/../../lockable_byte_io_handle.hpp:28:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_handle.hpp:28:
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1286:20: error: no member named 'state' in 'awaitable<T>'; did you mean '_state'?
 1286 |       switch(this->state)
      |                    ^~~~~
      |                    _state
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1195:25: note: '_state' declared here
 1195 |     io_operation_state *_state{nullptr};
      |                         ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1313:16: error: no member named 'h' in 'awaitable<T>'
 1313 |       if(this->h < o.h)
      |          ~~~~  ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1313:22: error: no member named 'h' in 'awaitable<T>'
 1313 |       if(this->h < o.h)
      |                    ~ ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1315:16: error: no member named 'visitor' in 'awaitable<T>'
 1315 |       if(this->visitor < o.visitor)
      |          ~~~~  ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1315:28: error: no member named 'visitor' in 'awaitable<T>'
 1315 |       if(this->visitor < o.visitor)
      |                          ~ ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1322:20: error: no member named 'h' in 'awaitable<T>'
 1322 |       return this->h == o.h && this->visitor == o.visitor && _identifying_address() == o._identifying_address();
      |              ~~~~  ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1322:27: error: no member named 'h' in 'awaitable<T>'
 1322 |       return this->h == o.h && this->visitor == o.visitor && _identifying_address() == o._identifying_address();
      |                         ~ ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1322:38: error: no member named 'visitor' in 'awaitable<T>'
 1322 |       return this->h == o.h && this->visitor == o.visitor && _identifying_address() == o._identifying_address();
      |                                ~~~~  ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../byte_io_multiplexer.hpp:1322:51: error: no member named 'visitor' in 'awaitable<T>'
 1322 |       return this->h == o.h && this->visitor == o.visitor && _identifying_address() == o._identifying_address();
      |                                                 ~ ^
In file included from foo.cpp:1:
In file included from /tmp/llfio/include/llfio.hpp:1:
In file included from /tmp/llfio/include/llfio/llfio.hpp:18:
In file included from /tmp/llfio/include/llfio/v2.0/llfio.hpp:67:
In file included from /tmp/llfio/include/llfio/v2.0/dynamic_thread_pool_group.hpp:526:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/dynamic_thread_pool_group.ipp:27:
In file included from /tmp/llfio/include/llfio/v2.0/detail/impl/../../file_handle.hpp:544:
/tmp/llfio/include/llfio/v2.0/detail/impl/../../detail/impl/posix/file_handle.ipp:689:10: warning: absolute value function 'abs' given an argument of type 'int64_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
  689 |       if(abs((int64_t) destoffset - (int64_t) extent.offset) < (int64_t) blocksize)
      |          ^
/tmp/llfio/include/llfio/v2.0/detail/impl/../../detail/impl/posix/file_handle.ipp:689:10: note: use function 'std::abs' instead
  689 |       if(abs((int64_t) destoffset - (int64_t) extent.offset) < (int64_t) blocksize)
      |          ^~~
      |          std::abs
1 warning and 9 errors generated.

Additional errors happen with libc++ in C++17 mode (not in 20+ though):

$ clang++ -c foo.cpp -stdlib=libc++ -I /tmp/llfio/include/ -I /tmp/quickcpplib/include/ -I /tmp/outcome/include/
In file included from foo.cpp:1:
In file included from /tmp/llfio/include/llfio.hpp:1:
In file included from /tmp/llfio/include/llfio/llfio.hpp:18:
In file included from /tmp/llfio/include/llfio/v2.0/llfio.hpp:58:
In file included from /tmp/llfio/include/llfio/v2.0/config.hpp:60:
In file included from /usr/bin/../include/c++/v1/iostream:42:
In file included from /usr/bin/../include/c++/v1/ios:220:
In file included from /usr/bin/../include/c++/v1/__locale:24:
In file included from /usr/bin/../include/c++/v1/string:647:
/usr/bin/../include/c++/v1/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits<llfio_v2_613d8707::detail::char8_t>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:460:22: note: in instantiation of template class 'std::basic_string_view<llfio_v2_613d8707::detail::char8_t>' requested here
  460 |     return _utf8 ? f(basic_string_view<char8_t>(_char8str, _length))  //
      |                      ^
/usr/bin/../include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
      |        ^
/usr/bin/../include/c++/v1/__string/char_traits.h:359:23: error: implicit instantiation of undefined template 'std::char_traits<llfio_v2_613d8707::detail::char8_t>'
  359 |   const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
      |                       ^
/usr/bin/../include/c++/v1/string_view:495:17: note: in instantiation of function template specialization 'std::__str_find<llfio_v2_613d8707::detail::char8_t, unsigned long, std::char_traits<llfio_v2_613d8707::detail::char8_t>, 18446744073709551615UL>' requested here
  495 |     return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
      |                 ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:502:69: note: in instantiation of member function 'std::basic_string_view<llfio_v2_613d8707::detail::char8_t>::find' requested here
  502 |       return _utf8 ? basic_string_view<char8_t>(_char8str, _length).find(preferred_separator, startidx)  //
      |                                                                     ^
/usr/bin/../include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
      |        ^
/usr/bin/../include/c++/v1/__string/char_traits.h:431:9: error: implicit instantiation of undefined template 'std::char_traits<llfio_v2_613d8707::detail::char8_t>'
  431 |     if (_Traits::eq(*--__ps, __c))
      |         ^
/usr/bin/../include/c++/v1/string_view:520:17: note: in instantiation of function template specialization 'std::__str_rfind<llfio_v2_613d8707::detail::char8_t, unsigned long, std::char_traits<llfio_v2_613d8707::detail::char8_t>, 18446744073709551615UL>' requested here
  520 |     return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
      |                 ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:546:69: note: in instantiation of member function 'std::basic_string_view<llfio_v2_613d8707::detail::char8_t>::rfind' requested here
  546 |       return _utf8 ? basic_string_view<char8_t>(_char8str, _length).rfind(preferred_separator, endidx)  //
      |                                                                     ^
/usr/bin/../include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
      |        ^
In file included from foo.cpp:1:
In file included from /tmp/llfio/include/llfio.hpp:1:
In file included from /tmp/llfio/include/llfio/llfio.hpp:18:
In file included from /tmp/llfio/include/llfio/v2.0/llfio.hpp:58:
In file included from /tmp/llfio/include/llfio/v2.0/config.hpp:60:
In file included from /usr/bin/../include/c++/v1/iostream:42:
In file included from /usr/bin/../include/c++/v1/ios:220:
In file included from /usr/bin/../include/c++/v1/__locale:24:
In file included from /usr/bin/../include/c++/v1/string:647:
/usr/bin/../include/c++/v1/string_view:559:37: error: implicit instantiation of undefined template 'std::char_traits<llfio_v2_613d8707::detail::char8_t>'
  559 |         data(), size(), __s, __pos, traits_type::length(__s));
      |                                     ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:634:37: note: in instantiation of member function 'std::basic_string_view<llfio_v2_613d8707::detail::char8_t>::find_first_of' requested here
  634 |       return string_view::npos != v.find_first_of(tofind);
      |                                     ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:460:20: note: in instantiation of function template specialization 'llfio_v2_613d8707::path_view_component::contains_glob()::(anonymous class)::operator()<std::basic_string_view<llfio_v2_613d8707::detail::char8_t>>' requested here
  460 |     return _utf8 ? f(basic_string_view<char8_t>(_char8str, _length))  //
      |                    ^
/tmp/llfio/include/llfio/v2.0/path_view.hpp:627:12: note: in instantiation of function template specialization 'llfio_v2_613d8707::path_view_component::_invoke<(lambda at /tmp/llfio/include/llfio/v2.0/path_view.hpp:627:20)>' requested here
  627 |     return _invoke([](const auto &v) {
      |            ^
/usr/bin/../include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
   45 | struct char_traits;
ned14 commented 2 weeks ago

Thanks for the BR

ned14 commented 2 weeks ago

That should be fixed now. Thanks for the report.

We can't fix libc++ in C++ 17. There is no official char_t so we try to use a standin if in 17. libc++ used to allow this with a warning, then they removed it. As LLFIO's path_view is implemented using the codecv et al, this effectively made libc++ + C++ 17 not supported in new enough libc++'s. Either use an older libc++, or use C++ 20 or later. Sorry.

jcelerier commented 2 weeks ago

I'm mostly on C++23 so I'm not impacted by that at all thankfully aha, I was just reporting that in case it was a goal for the library to be compatible with older standards