https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88889

            Bug ID: 88889
           Summary: [9 Regression] New valgrind warning since r261039
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

I've just isolated a test-case from curl package and there's a new valgrind
error:

$ cat lib1560.c
void
__attribute__((noipa))
updateurl(const char *p)
{
  char part[16];
  if(1 == __builtin_sscanf(p, "%1[^=]=", part)) {
    {
      __builtin_printf ("part:%s\n", part);
      int what = __builtin_strcmp("1234567", part);
      if(!what)
        __builtin_abort ();
    }
  }
}

int main()
{
  updateurl("a=");
  return 0;
}

$ gcc lib1560.c -O2 -g && valgrind ./a.out 
==4115== Memcheck, a memory error detector
==4115== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4115== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==4115== Command: ./a.out
==4115== 
part:a
==4115== Conditional jump or move depends on uninitialised value(s)
==4115==    at 0x40119D: updateurl (lib1560.c:9)
==4115==    by 0x40106D: main (lib1560.c:18)

we correctly emit:
what_7 = __builtin_strcmp_eq ("1234567", &part, 8);

which is transformed into following assembly:

        movabsq $15540725856023089, %rax
        cmpq    %rax, (%rsp)

That's correct transformation, but as part[2:] is uninitialized, valgrind
complains about comparison of the uninitialized bytes of 'part'.

What to do with that?

Reply via email to