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

            Bug ID: 489707
           Summary: Conditional jump or move depends on uninitialised
                    value(s)" shouldn't apply to assertions.
    Classification: Developer tools
           Product: valgrind
           Version: 3.23.0
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: dan...@mariadb.org
  Target Milestone: ---

SUMMARY

Defensive code can use assertions around uninitialised values to protect
against undefined behaviour. While valgrind does the same thing, to do both
there is now a different compile option to test under valgrind.

STEPS TO REPRODUCE

1. t.c

#include <assert.h>

int main()
{
  unsigned long n;
  char *b = (char *) &n;

  *b = 1;
  assert((n & ~0xFFUL) == 0);

}

2.  gcc -o /tmp/t /tmp/t.c
3. valgrind /tmp/t

OBSERVED RESULT

==1111332== Conditional jump or move depends on uninitialised value(s)
==1111332==    at 0x401147: main (in /tmp/t)

EXPECTED RESULT

no error.

SOFTWARE/OS VERSIONS

Linux (Fedora 40)
(gcc 14.1.1)

ADDITIONAL INFORMATION

This didn't trigger as error on valgrind 3.18.1.

ref: https://jira.mariadb.org/browse/MDEV-34502
and workaround: https://github.com/MariaDB/server/pull/3378
notably: valgrind didn't error on the subsequent statements reading n

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

Reply via email to