[llvm-bugs] [Bug 42392] New: Please improve -Wuninitialized warnings for OpenMP programs

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 25 14:16:03 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42392

            Bug ID: 42392
           Summary: Please improve -Wuninitialized warnings for OpenMP
                    programs
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vyacheslav.p.zakharin at intel.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The code below compiles silently with "-fopenmp -fopenmp-targets=x86_64".  W/o
-fopenmp the errors become obvious:
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]

Can this be improved?

-- code --
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;
}
-- code --

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190625/b78adcbb/attachment.html>


More information about the llvm-bugs mailing list