This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
no warning for undeclared threadprivate variable
- From: Andrew Benson <abenson at its dot caltech dot edu>
- To: fortran at gcc dot gnu dot org
- Date: Thu, 14 Jul 2011 20:14:49 -0700
- Subject: no warning for undeclared threadprivate variable
Working on some OpenMP code I was surprised to find that the following doesn't
emit any warning or error:
module OMP_Test
double precision :: myVar
!$omp threadprivate(notMyVar)
end module OMP_Test
I'm compiling this using:
gfortran -c ompTest.F90 -fopenmp -Wall
with:
gcc version 4.6.0 20110530 (Red Hat 4.6.0-9) (GCC)
Reading from the OpenMP standard: " A variable can only appear in a
threadprivate directive in the scope in which it is declared. It must not be
an element of a common block or appear in an EQUIVALENCE statement."
I would have guessed that this would make the above invalid code, since
"notMyVar" isn't declared in the scope of the threadprivate directive (or
anywhere else for that matter). Could be I'm missing the meaning of the OpenMP
standard of course.
If I try the same within the scope of a subroutine I at least get an error
that "notMyVar" isn't SAVEd.
A warning or error would be very useful - I had a typo in a threadprivate
declaration which resulted in my code crashing (since the variable I'd
intended to be threadprivate, wasn't).
Thanks,
Andrew.
--
* Andrew Benson: http://www.tapir.caltech.edu/~abenson/contact.html
* Galacticus: http://sites.google.com/site/galacticusmodel