From 6b2103960c02715f3525627f54931dff2973427e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=81o=C5=9B?= Date: Wed, 8 May 2024 14:08:42 +0200 Subject: [PATCH] Add compilation test instead of VxWorks check `` is explicitly excluded for VxWork, because enabling it causes compilation error when building tests (and causes some serious issues when trying to naively work-arond this compilation problem). When forcing `QT_FEATURE_cxx11_future` on VxWorks, failure occurs: ``` qtbase/src/corelib/thread/qthread.h:125:19: error: no matching function for call to 'invoke' 125 | (void)std::invoke(std::move(f), std::forward(largs)...); | ^~~~~~~~~~~ [...] qtbase/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp:32:45: note: in instantiation of function template specialization 'QThread::create<(lambda at qtbase/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp:32:52), QPromise>' requested here 32 | QScopedPointer thread(QThread::create([] (QPromise promise) { | ^ VSB/usr/h/public/type_traits:2720:7: note: candidate template ignored: substitution failure [with _Callable = remove_reference_t<(lambda at qtbase/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp:32:52) &>, _Types = &>]: no matching function for call to '_Call' 2720 | auto invoke(_Callable&& _Obj, _Types&&... _Args) noexcept(noexcept(_Invoker<_Callable, _Types...>::_Call( | ^ 2721 | _STD forward<_Callable>(_Obj), _STD forward<_Types>(_Args)...))) 2722 | -> decltype(_Invoker<_Callable, _Types...>::_Call( | ~~~~~~~~ ``` Instead of excluding cxx11_future on VxWorks explicitly, replace condition with actual check which should pass in non-VxWorks 24.03 (or older) standard libraries. VxWorks in version 24.03 fails this test due to std::async improperly forwards argument type to lambda, which causes compilation error when argument type is a non-copiable value type. This is a problem in VxWorks standard library, which could be fixed in future versions of this OS, so keeping this as a test should unlock `` header once it's fixed. Task-number: QTBUG-115777 Change-Id: Ic67df9be2e95dce999689eaea146f113017ab4f3 Reviewed-by: Thiago Macieira (cherry picked from commit ced943e936e335a16e9b479a2010e5bbee1af4f1) --- src/corelib/configure.cmake | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 9da9c332f80..0d8ad6fafd1 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -411,6 +411,34 @@ int main(void) } ") +# +qt_config_compile_test(cxx_std_async_noncopyable + LABEL "std::async() NonCopyable" + CODE +"// Calling std::async with lambda which takes non-copyable argument causes compilation error on +// some platforms (VxWorks 24.03 and older with C++17-compatibility for example) +#include + +class NonCopyable { +public: + NonCopyable(const NonCopyable&) = delete; + NonCopyable(NonCopyable&&) = default; + + NonCopyable(int value) + :value (value) + {} + + int value; +}; + +int main(int argc, char** argv) { + return std::async( + std::launch::deferred, + [](NonCopyable value) { return value.value; }, + NonCopyable(argc - 1)).get(); +} +") + #### Features qt_feature("clock-gettime" PRIVATE @@ -439,7 +467,7 @@ qt_feature("system-doubleconversion" PRIVATE ) qt_feature("cxx11_future" PUBLIC LABEL "C++11 " - CONDITION ON + CONDITION TEST_cxx_std_async_noncopyable ) qt_feature("cxx17_filesystem" PUBLIC LABEL "C++17 "