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: unassignedclangb...@nondot.org
          Reporter: vyacheslav.p.zakha...@intel.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to