Bug 24612 - [gomp] Bogus "is used uninitialized" warning
Summary: [gomp] Bogus "is used uninitialized" warning
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Richard Henderson
URL:
Keywords: diagnostic, openmp
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2005-11-01 11:04 UTC by Volker Reichelt
Modified: 2005-11-06 00:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-05 23:33:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.