diff --git a/include/alpaka/core/ThreadPool.hpp b/include/alpaka/core/ThreadPool.hpp index 51bc6cb5434f..e99d41628e8c 100644 --- a/include/alpaka/core/ThreadPool.hpp +++ b/include/alpaka/core/ThreadPool.hpp @@ -55,7 +55,7 @@ namespace alpaka::core::detail template auto enqueueTask(TFnObj&& task, TArgs&&... args) -> std::future { - auto ptask = Task{[=, t = std::forward(task)] { t(args...); }}; + auto ptask = Task{[=, t = std::forward(task)]() noexcept(noexcept(task(args...))) { t(args...); }}; auto future = ptask.get_future(); { std::lock_guard lock{m_mutex}; diff --git a/test/unit/core/src/ThreadPool.cpp b/test/unit/core/src/ThreadPool.cpp index ed8299ec3b51..5819f281db5f 100644 --- a/test/unit/core/src/ThreadPool.cpp +++ b/test/unit/core/src/ThreadPool.cpp @@ -1,4 +1,4 @@ -/* Copyright 2023 Bernhard Manfred Gruber +/* Copyright 2023 Bernhard Manfred Gruber, Jan Stephan * SPDX-License-Identifier: MPL-2.0 */ @@ -18,7 +18,7 @@ TEST_CASE("threadpool", "[core]") auto f1 = tp.enqueueTask([] { throw std::runtime_error("42"); }); auto f2 = tp.enqueueTask([] { throw 42; }); - auto f3 = tp.enqueueTask([] {}); + auto f3 = tp.enqueueTask([]() noexcept {}); CHECK_THROWS_AS(f1.get(), std::runtime_error);