User account creation filtered due to spam.

Bug 24612

Summary: [gomp] Bogus "is used uninitialized" warning
Product: gcc Reporter: Volker Reichelt <reichelt>
Component: middle-endAssignee: Richard Henderson <rth>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3 Keywords: diagnostic, openmp
Version: unknown   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-11-05 23:33:15
Bug Depends on:    
Bug Blocks: 24639    

Description Volker Reichelt 2005-11-01 11:04:07 UTC
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
Comment 1 Jakub Jelinek 2005-11-02 08:23:09 UTC
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.
Comment 2 Richard Henderson 2005-11-03 02:18:10 UTC
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.
Comment 3 Richard Henderson 2005-11-06 00:55:47 UTC
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

Comment 4 Richard Henderson 2005-11-06 00:56:13 UTC
Fixed.