https://bugs.kde.org/show_bug.cgi?id=437790

            Bug ID: 437790
           Summary: valgrind reports "Conditional jump or move depends on
                    uninitialised value" in memchr of macOS 10.15
           Product: valgrind
           Version: unspecified
          Platform: MacPorts Packages
                OS: macOS
            Status: REPORTED
          Severity: minor
          Priority: NOR
         Component: memcheck
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

SUMMARY

valgrind reports "Conditional jump or move depends on uninitialised value" in
memchr of macOS 10.15 with a very simple program test:

#include <stdio.h>
#include <string.h>

# cat test.c
int main(int argc, char *argv[])
{
  char strval[100];
  int len = sprintf(strval, "%.7G", 10.);
  if(memchr(strval, '.', len))
     printf("IF len %d\n", len);
  else
     printf("ELSE len %d\n", len);
}


STEPS TO REPRODUCE
1. In a macOS 10.15:
   $ cc -o test test.c
2. valgrind test



OBSERVED RESULT
3. Results:
==51455== Conditional jump or move depends on uninitialised value(s)
==51455==    at 0x100617108: _platform_memchr$VARIANT$Base (in
/usr/lib/system/libsystem_platform.dylib)
==51455==    by 0x100003ECB: main (kk.c:11)

EXPECTED RESULT

 According to POSIX
(https://pubs.opengroup.org/onlinepubs/9699919799/functions/memchr.html) memchr
should behave as it would read byte by byte until the character is found up to
the len parameter. Since len is also the number of characters written by
sprintf it shouldn't be the case that memchr reads uninitialised values

SOFTWARE/OS VERSIONS
macOS: 10.15
valgrind valgrind-3.17.0.GIT-lbmacos installed from macports.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to