[Bf-blender-cvs] [a9c74a0cd0d] master: Fix set iterator test failure on macOS

Julian Eisel noreply at git.blender.org
Thu Jul 28 23:54:19 CEST 2022


Commit: a9c74a0cd0dfea7d97bbca5e490a5dafdbae3b41
Author: Julian Eisel
Date:   Thu Jul 28 23:50:40 2022 +0200
Branches: master
https://developer.blender.org/rBa9c74a0cd0dfea7d97bbca5e490a5dafdbae3b41

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.

===================================================================

M	source/blender/blenlib/tests/BLI_set_test.cc

===================================================================

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<int>::iterator iter1 = set.begin();
   int value1 = *iter1;
   Set<int>::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<int>::iterator iter3 = ++iter1;
+  /* Check that #iter1 itself changed. */
+  EXPECT_EQ(*iter3, *iter1);
 }
 
 TEST(set, GenericAlgorithms)



More information about the Bf-blender-cvs mailing list