]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Darwin regtest: small tweak for memcheck str_tester
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 13 Mar 2026 12:40:37 +0000 (13:40 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 13 Mar 2026 12:47:08 +0000 (13:47 +0100)
On Darwin 17 (macOs 10.13) this test fails standalone and under
Valgrind.

The failing test is

  check(memcmp("a\203", "a\003", 2) > 0, 6);

I think that the compiler is using a builtin that does not behave
identically to libc memcmp. It's all a quastion of signed and
unsigned char. If char is unsigned then \203 is positive and
greater than \003. This is the Darwin libc behaviour. If
char is signed \203 is negative and the return value is negative
and the test fails.  That seems to be the builtin behaviour.

This change inhibits use of a builtin for that one test.

memcheck/tests/str_tester.c

index 1201bbfc225b27d3364d3e8c65f7f3589ca91cab..01c5834099244410d18da160771d3a3bb4a56250 100644 (file)
@@ -984,7 +984,8 @@ test_memcmp (void)
   check(memcmp("abcd", "abce", 4) < 0, 3);     /* Honestly unequal. */
   check(memcmp("abce", "abcd", 4) > 0, 4);
   check(memcmp("alph", "beta", 4) < 0, 5);
-  check(memcmp("a\203", "a\003", 2) > 0, 6);
+  // Darwin 17 uses a builtin which fails test 6. Use parens to inhibit the use of builtins.
+  check((memcmp)("a\203", "a\003", 2) > 0, 6);
   check(memcmp("abce", "abcd", 3) == 0, 7);    /* Count limited. */
   check(memcmp("abc", "def", 0) == 0, 8);      /* Zero count. */
 }