Compiling the following code with "-fopenmp -O -Wall" yields a bogus warning (happens with C and C++): ====================================== void foo() { int i; #pragma omp threadprivate(i) #pragma omp parallel sections { #pragma omp section { i = 0; ++i; } } } ====================================== bug.c: In function 'foo': bug.c:11: warning: 'i' is used uninitialized in this function
That testcase is IMHO invalid (see http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00099.html ), but void foo (void) { int i; #pragma omp parallel sections shared (i) { #pragma omp section { i = 0; ++i; } } } which is valid warns too.
Hum. I suppose we could just mark the variable TREE_NO_WARNING. Our only other option is to pass by reference, and that would suppress any legitimate warnings as well.
Subject: Bug 24612 Author: rth Date: Sun Nov 6 00:55:43 2005 New Revision: 106551 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106551 Log: PR middle-end/24612 * omp-low.c (expand_rec_input_clauses): Set TREE_NO_WARNING for pass-by-value shared variables. Added: branches/gomp-20050608-branch/gcc/testsuite/gcc.dg/gomp/uninit-1.c Modified: branches/gomp-20050608-branch/gcc/ChangeLog.gomp branches/gomp-20050608-branch/gcc/omp-low.c
Fixed.