Skip to content

Commit

Permalink
Fix some compiler issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Dec 9, 2024
1 parent 8aef5cf commit 60b7dc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions lib/genesis/utils/threading/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,24 +702,29 @@ class ThreadPool
inline auto make_task_function_( F&& f, Args&&... args )

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]

Check failure on line 702 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

unused parameter 'args' [-Werror,-Wunused-parameter]
-> std::function<typename genesis_invoke_result<F, Args...>::type ()>
{
// Unfortunately, Clang 18 uses std::result_of within std::bind, which is however deprecated,
// Unfortunately, Clang 18 when compiled under the C++20 standard somehow uses
// std::result_of within std::bind, despite that being deprecated in the standard,
// and hence leads to a warning, and as we set warnings as errors, fails to compile.
// See https://gcc.gnu.org/pipermail/libstdc++/2024-March/058502.html for details.
// This is the reason why we internally use genesis_invoke_result instead, to switch
// between the two. But doesn't work of course for the STL... So we need to silence this.
// between the two. But doesn't work of course for the STL...
// So we need a workaround for this. Silencing via #pragma diagnostic does not seem
// to work, so instead, we just completely get rid of the std::bind for C++ standards
// that support variadic lambda captures.
// This is the whole reason for this function. Super ugly, but it is what it is.
#if defined(__clang__) && (__clang_major__ == 18)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#if GENESIS_CPP_STD >= GENESIS_CPP_STD_17

// Use a modern way to bind the args to the function.
return [f = std::forward<F>(f), ...args = std::forward<Args>(args)]() mutable

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

expected identifier before ‘...’ token

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-6)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-7)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-22.04, llvm-8)

expected variable name or 'this' in lambda capture list

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-24.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-24.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’

Check failure on line 718 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-24.04, gcc-9)

pack init-capture only available with ‘-std=c++2a’ or ‘-std=gnu++2a’
{
return f(args...);

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

‘args’ is not captured

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

‘args’ is not captured

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

‘args’ is not captured

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

‘args’ is not captured

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

‘args’ is not captured

Check failure on line 720 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

‘args’ is not captured
};

Check failure on line 721 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

could not convert ‘<lambda closure object>genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>{genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>((* & std::forward<genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()> >((* & f))))}’ from ‘genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>’ to ‘std::function<long unsigned int()>’

Check failure on line 721 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-7)

could not convert ‘<lambda closure object>genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>{genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>((* & std::forward<genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()> >((* & f))))}’ from ‘genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>’ to ‘std::function<long unsigned int()>’

Check failure on line 721 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

could not convert ‘<lambda closure object>genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>{genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>((* & std::forward<genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()> >((* & f))))}’ from ‘genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>’ to ‘std::function<long unsigned int()>’

Check failure on line 721 in lib/genesis/utils/threading/thread_pool.hpp

View workflow job for this annotation

GitHub Actions / ci (ubuntu-20.04, gcc-8)

could not convert ‘<lambda closure object>genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>{genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>((* & std::forward<genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()> >((* & f))))}’ from ‘genesis::utils::ThreadPool::make_task_function_(F&&, Args&& ...) [with F = genesis::utils::AsynchronousReader::start_reading(char*, size_t)::<lambda()>; Args = {}; typename genesis::utils::genesis_invoke_result<F, Args ...>::type = long unsigned int]::<lambda()>’ to ‘std::function<long unsigned int()>’

#else

// Make the function via binding.
return std::bind( std::forward<F>(f), std::forward<Args>(args)... );
// Make the function via binding.
return std::bind( std::forward<F>(f), std::forward<Args>(args)... );

// Undo the silencing.
#if defined(__clang__) && (__clang_major__ == 18)
#pragma clang diagnostic pop
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/utils/threading/concurrent_vector_guard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST( Threading, VectorEntries )
// them from their vec within data, until empty, and then moves to the next one.
auto thread_pool = std::make_shared<ThreadPool>( num_threads );
auto vector_guard = ConcurrentVectorGuard( num_vecs );
std::atomic<size_t> num_elem = 0;
auto num_elem = std::atomic<size_t>{0};
for( size_t t = 0; t < num_threads; ++t ) {
thread_pool->enqueue_detached([&, t]()
{
Expand Down

0 comments on commit 60b7dc2

Please sign in to comment.