From b1f90dc58c570d7cbe9c0bfc333b27adca0d8f6d Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Fri, 13 Sep 2024 15:01:03 +0100 Subject: [PATCH] [UnitCL] Fix C11Atomics_73_*, C11Atomics_74_*, C11Atomics_75_* These tests test atomic_compare_exchange_weak_explicit which is allowed to fail for no clear reason. The test tries to account for this by detecting output differences, using that to set a weak_exchange_failed boolean, and using that weak_exchange_failed boolean to detect where the result of atomic_compare_exchange_weak_explicit does not match expectations. That is, in output_reference, it does: if (value == expected_values[success_index]) { weak_exchange_failed = true; return true; } Then, bool_output_reference is: [success_index, weak_exchange_failed](size_t index) { return index == success_index && !weak_exchange_failed; }; The problem here is that bool_output_reference is constructed capturing weak_exchange_failed by value, so it will never pick up the updated value even if it was detected that the weak exchange had failed. To fix this, capture it by reference instead. --- source/cl/test/UnitCL/source/C11Atomics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cl/test/UnitCL/source/C11Atomics.cpp b/source/cl/test/UnitCL/source/C11Atomics.cpp index dcc84cb19..0c4ed447e 100644 --- a/source/cl/test/UnitCL/source/C11Atomics.cpp +++ b/source/cl/test/UnitCL/source/C11Atomics.cpp @@ -2365,7 +2365,7 @@ class WeakGlobalSingle : public C11AtomicTestBase { return desired_values[index]; }; kts::Reference1D bool_output_reference = - [success_index, weak_exchange_failed](size_t index) { + [success_index, &weak_exchange_failed](size_t index) { return index == success_index && !weak_exchange_failed; };