|
From: Paul F. <pa...@so...> - 2026-03-13 12:48:47
|
https://sourceware.org/cgit/valgrind/commit/?id=58bb429efb320233aa433356ce7e1f9a343b2d62 commit 58bb429efb320233aa433356ce7e1f9a343b2d62 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 13 13:40:37 2026 +0100 Darwin regtest: small tweak for memcheck str_tester 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. Diff: --- memcheck/tests/str_tester.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memcheck/tests/str_tester.c b/memcheck/tests/str_tester.c index 1201bbfc22..01c5834099 100644 --- a/memcheck/tests/str_tester.c +++ b/memcheck/tests/str_tester.c @@ -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. */ } |