On 09/08/2016 04:56 AM, Mark Wielaard wrote:
I don't think there is anything valgrind can do to detect that
compw really only depends on d[0] if the result is false.
valgrind (with the default --partial-loads-ok=yes) could and should do
the same thing with cmpw that it already does with cmpl. The attached
program compiles and runs OK with gcc -O2 and valgrind on x86-64, even
though the machine code uses cmpl to load bytes that were not allocated.
Do gnulib and glibc syncronize?
They do at times, though not as often as we'd like. fts.c in particular
has strayed quite a bit, to cater GNU utilities' robustness needs over
what glibc provides. (GNU coreutils, for example, uses Gnulib fts.c even
on glibc platforms.) At some point somebody should merge Gnulib fts.c
back into glibc.
#include <stddef.h>
#include <stdlib.h>
struct s { struct s *next; char d[]; };
int
main (void)
{
struct s *p = malloc (offsetof (struct s, d) + 1);
p->d[0] = 1;
return p->d[0] == 2 && p->d[1] == 3 && p->d[2] == 4 && p->d[3] == 5;
}