[Bug fortran/89651] OpenMP private array uninitialized warning with -O flag

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Mar 11 18:56:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89651

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jim Feng from comment #5)
> (In reply to Jakub Jelinek from comment #4)
> > On the other side, the testcase is invalid, because you are summing
> > uninitialized data.  It is like if you did:
> > program pr89651
> >   integer :: n
> >   real, allocatable :: t(:)
> >   n = 10
> >   allocate (t(n))
> >   print *, sum (t)
> > end program pr89651
> > but it is true gfortran doesn't warn here either.  And we do warn even with
> > firstprivate(t) when it is not undefined.
> 
> In the test case, the array is initialized:
> 
> allocate(t(n),source=0.0)

Outside of the OpenMP region yes, but you are using private clause, and the
privatized variable is just allocated, but not initialized.  You'd need to use
firstprivate(t) clause instead to copy the data too.


More information about the Gcc-bugs mailing list