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

Make zug::compat::invoke work with pointer-to-member function #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tusooa
Copy link
Contributor

@tusooa tusooa commented Feb 5, 2024

Copy link
Owner

@arximboldi arximboldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM even though it would be nice to have tests that cover the 4 overload cases (it seems to me some are not covered here potentially). Either way thanks a lot for the contribution!

@arximboldi
Copy link
Owner

Uhhh... tests are failing. Could you maybe look into why?

@tusooa tusooa force-pushed the tusooa/wrong-overload-pmf branch from 065d97b to 8994f2a Compare February 6, 2024 23:55
@tusooa
Copy link
Contributor Author

tusooa commented Feb 7, 2024

Uhhh... tests are failing. Could you maybe look into why?

I can't reproduce this locally using GCC 13.2.1 on Gentoo Linux, even with -Werror=array-bounds compiler option set.

@arximboldi
Copy link
Owner

You should be able to reproduce it using nix-shell --argstr compiler gcc like CI does.

@tusooa
Copy link
Contributor Author

tusooa commented Jul 6, 2024

Yea, I can reproduce the error in nix but I have totally no idea why it fails.

[ 61%] Building CXX object test/CMakeFiles/test-transducer-read.dir/transducer/read.cpp.o
In file included from /home/user/Code/zug/zug/compose.hpp:11,
                 from /home/user/Code/zug/zug/transducer/map.hpp:11,
                 from /home/user/Code/zug/test/transducer/map.cpp:12:
In function 'decltype ((forward<Derived>)(zug::compat::detail::do_invoke::ref).*zug::compat::detail::do_invoke::pmf((forward<Args>)(zug::compat::detail::do_invoke::args)...)) zug::compat::detail::do_invoke(T Base::*, Derived&&, Args&& ...) [with Base = {anonymous}::Foo; T = const int&() const; Derived = {anonymous}::Foo&; Args = {}; <template-parameter-1-5> = void]',
    inlined from 'decltype (zug::compat::detail::do_invoke(forward<F>(f), (forward<ArgTypes>)(zug::compat::invoke::args)...)) zug::compat::invoke(F&&, ArgTypes&& ...) [with F = const int& ({anonymous}::Foo::*&)() const; ArgTypes = {{anonymous}::Foo&}]' at /home/user/Code/zug/zug/compat/invoke.hpp:54:29,
    inlined from 'zug::map_t<const int& ({anonymous}::Foo::*)() const>::operator()<const zug::output_t&>(const zug::output_t&) const::<lambda(auto:1&&, auto:2&& ...)> mutable [with auto:1 = std::back_insert_iterator<std::vector<int> >; auto:2 = {{anonymous}::Foo&}]' at /home/user/Code/zug/zug/transducer/map.hpp:23:24,
    inlined from 'std::decay_t<decltype (step(initial, (* std::begin(range))))> zug::detail::reduce_nested_non_empty_non_variadic(ReducingFnT&&, StateT&&, InputRangeT&&) [with ReducingFnT = zug::map_t<const int& ({anonymous}::Foo::*)() const>::operator()<const zug::output_t&>(const zug::output_t&) const::<lambda(auto:1&&, auto:2&& ...)>; StateT = std::back_insert_iterator<std::vector<int> >; InputRangeT = std::vector<{anonymous}::Foo>&]' at /home/user/Code/zug/zug/detail/reduce_nested_non_empty_non_variadic.hpp:33:13,
    inlined from 'decltype(auto) zug::detail::reduce_nested_non_empty(ReducingFnT&&, StateT&&, InputRangeT&&) [with ReducingFnT = zug::map_t<const int& ({anonymous}::Foo::*)() const>::operator()<const zug::output_t&>(const zug::output_t&) const::<lambda(auto:1&&, auto:2&& ...)>; StateT = std::back_insert_iterator<std::vector<int> >; InputRangeT = std::vector<{anonymous}::Foo>&]' at /home/user/Code/zug/zug/detail/reduce_nested_non_empty.hpp:51:57,
    inlined from 'auto zug::reduce(ReducingFnT&&, StateT&&, InputRangeTs&& ...) [with ReducingFnT = map_t<const int& ({anonymous}::Foo::*)() const>::operator()<const zug::output_t&>(const zug::output_t&) const::<lambda(auto:1&&, auto:2&& ...)>; StateT = std::back_insert_iterator<std::vector<int> >; InputRangeTs = {std::vector<{anonymous}::Foo, std::allocator<{anonymous}::Foo> >&}]' at /home/user/Code/zug/zug/reduce.hpp:72:64,
    inlined from 'std::decay_t<StateT> zug::transduce(XformT&&, ReducingFnT&&, StateT&&, InputRangeTs&& ...) [with XformT = composed<map_t<const int& ({anonymous}::Foo::*)() const> >; ReducingFnT = const output_t&; StateT = std::back_insert_iterator<std::vector<int> >; InputRangeTs = {std::vector<{anonymous}::Foo, std::allocator<{anonymous}::Foo> >&}]' at /home/user/Code/zug/zug/transduce.hpp:31:18,
    inlined from 'CollectionT&& zug::into(CollectionT&&, XformT&&, InputRangeTs&& ...) [with CollectionT = std::vector<int>; XformT = composed<map_t<const int& ({anonymous}::Foo::*)() const> >; InputRangeTs = {std::vector<{anonymous}::Foo, std::allocator<{anonymous}::Foo> >&}]' at /home/user/Code/zug/zug/into.hpp:34:14,
    inlined from 'std::vector<typename zug::result_of<XformT, typename std::decay<InputRangeTs>::type::value_type ...>::type> zug::into_vector(XformT&&, InputRangeTs&& ...) [with XformT = composed<map_t<const int& ({anonymous}::Foo::*)() const> >; InputRangeTs = {std::vector<{anonymous}::Foo, std::allocator<{anonymous}::Foo> >&}]' at /home/user/Code/zug/zug/into_vector.hpp:35:54,
    inlined from 'void C_A_T_C_H_T_E_S_T_6()' at /home/user/Code/zug/test/transducer/map.cpp:55:44:
/home/user/Code/zug/zug/compat/invoke.hpp:37:40: error: array subscript 'int (**)(...)[0]' is partly outside array bounds of 'unsigned char [4]' [-Werror=array-bounds]
   37 |                                    pmf)(std::forward<Args>(args)...))
      |                                        ^
/home/user/Code/zug/zug/compat/invoke.hpp:20:35: note: in definition of macro 'ZUG_DETAIL_DECLTYPE_RETURN'
   20 |     decltype(body_expr) { return (body_expr); }
      |                                   ^~~~~~~~~
In file included from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/allocator.h:46,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/string:41,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/locale_classes.h:40,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/ios_base.h:41,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/streambuf:41,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/streambuf_iterator.h:35,
                 from /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/iterator:66,
                 from /home/user/Code/zug/zug/detail/is_non_empty.hpp:11,
                 from /home/user/Code/zug/zug/reduce.hpp:11,
                 from /home/user/Code/zug/zug/transduce.hpp:11,
                 from /home/user/Code/zug/zug/into.hpp:13,
                 from /home/user/Code/zug/test/transducer/map.cpp:9:
In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = {anonymous}::Foo]',
    inlined from 'static _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = {anonymous}::Foo]' at /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/alloc_traits.h:464:28,
    inlined from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = {anonymous}::Foo; _Alloc = std::allocator<{anonymous}::Foo>]' at /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/stl_vector.h:378:33,
    inlined from 'void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const {anonymous}::Foo*; _Tp = {anonymous}::Foo; _Alloc = std::allocator<{anonymous}::Foo>]' at /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/stl_vector.h:1687:25,
    inlined from 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = {anonymous}::Foo; _Alloc = std::allocator<{anonymous}::Foo>]' at /nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/stl_vector.h:677:21,
    inlined from 'void C_A_T_C_H_T_E_S_T_6()' at /home/user/Code/zug/test/transducer/map.cpp:54:34:
/nix/store/kf147vkmb7a7z17lkpgj2d6y7w75nf7v-gcc-12.2.0/include/c++/12.2.0/bits/new_allocator.h:137:55: note: object of size 4 allocated by 'operator new'
  137 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
      |                                                       ^
cc1plus: all warnings being treated as errors

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

Successfully merging this pull request may close these issues.

2 participants