[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [valgrind] [Bug 330617] ppc false positive conditional jump depends on uninitialised value
From:       Hal Finkel <hfinkel () anl ! gov>
Date:       2014-01-31 18:07:55
Message-ID: bug-330617-17878-DTJFrLO0bp () http ! bugs ! kde ! org/
[Download RAW message or body]

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

--- Comment #1 from Hal Finkel <hfinkel@anl.gov> ---
It had been suggested to me that this problem might not be ppc specific; I've
two comments on that:

1. The same code will not have the same problem on x86, because on x86 the bit
fields are laid out low-bit first (and so the undefined bits will be the high
bits and not the low bits as on ppc.

2. I wrote a simple test in an attempt to reproduce the problem on x86:
valgrind does not report a false positive on the following code when compiled
with Clang trunk on x86 (even though the optimizers do the same optimization
that proves problematic to valgrind on ppc):

#include <stdio.h>

struct s {
#if defined(__ppc__) || defined(__ppc64__)
  unsigned h : 3;
  unsigned l : 5;
#else
  unsigned l : 5;
  unsigned h : 3;
#endif
};

void __attribute__ ((noinline)) init(struct s *v) {
  v->h = 0;
}

void __attribute__ ((noinline)) foo(struct s *v) {
  if (v->h == 0) {
    printf("yep, it is zero\n");
  }
}

int main() {
  struct s v;
  init(&v);
  foo(&v);
  return 0;
}

On the other hand, when run on pp64, valgrind does (incorrectly) complain:

==45300== Conditional jump or move depends on uninitialised value(s)
==45300==    at 0x10000578: foo (bf2.c:18)
==45300==    by 0x100005D7: main (bf2.c:26)

-- 
You are receiving this mail because:
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic