[cfe-dev] missing -Wuninitialized warnings with OpenMP

Zakharin, Vyacheslav P via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 24 13:27:54 PDT 2019


Hello,

Is it possible to get appropriate -Wuninitialized warnings with OpenMP for the following cases?

int reduction(int *input) {
  int i, r;
#pragma omp target parallel for map(to: input) reduction(+: r)
  for (i = 0; i < 100; ++i)
    r += input[i];

  return r;
}

int linear() {
  int i, r;
#pragma omp target parallel for linear(r)
  for (i = 0; i < 100; ++i)
    r += 1;

  return r;
}
void firstprivate(int *input) {
  int r;
#pragma omp target firstprivate(r) map(tofrom: input[0:1])
  *input = r;
}

It compiles silently with -fopenmp, but the errors become obvious w/o it:
warn.c:5:5: warning: variable 'r' is uninitialized when used here [-Wuninitialized]
warn.c:14:5: warning: variable 'r' is uninitialized when used here [-Wuninitialized]
warn.c:21:12: warning: variable 'r' is uninitialized when used here [-Wuninitialized]

Is it worth a tracker?

Thanks,
Slava
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190624/596f676c/attachment.html>


More information about the cfe-dev mailing list