From a9c74a0cd0dfea7d97bbca5e490a5dafdbae3b41 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 28 Jul 2022 23:50:40 +0200 Subject: [PATCH] Fix set iterator test failure on macOS This is a quite interesting case, where two arguments to a function are evaluated in different order on Apple Clang than on GCC and I guess MSVC. Left a comment on that. --- source/blender/blenlib/tests/BLI_set_test.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc index 42a0d229b77..9dfa48b5822 100644 --- a/source/blender/blenlib/tests/BLI_set_test.cc +++ b/source/blender/blenlib/tests/BLI_set_test.cc @@ -532,8 +532,14 @@ TEST(set, ForwardIterator) Set::iterator iter1 = set.begin(); int value1 = *iter1; Set::iterator iter2 = iter1++; - EXPECT_EQ(*iter1, *(++iter1)); EXPECT_EQ(*iter2, value1); + EXPECT_EQ(*(++iter2), *iter1); + /* Interesting find: On GCC & MSVC this will succeed, as the 2nd argument is evaluated before the + * 1st. On Apple Clang it's the other way around, and the test fails. */ + // EXPECT_EQ(*iter1, *(++iter1)); + Set::iterator iter3 = ++iter1; + /* Check that #iter1 itself changed. */ + EXPECT_EQ(*iter3, *iter1); } TEST(set, GenericAlgorithms)