[cfe-dev] missing -Wuninitialized warnings with OpenMP

Finkel, Hal J. via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 25 13:59:35 PDT 2019


On 6/24/19 3:27 PM, Zakharin, Vyacheslav P via cfe-dev wrote:
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?


Yes, I think that filing a bug would be useful.

Thanks again,

Hal


Thanks,
Slava



_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190625/ff05e920/attachment.html>


More information about the cfe-dev mailing list