public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40876]  New: OpenMP private variable referenced in a statement function
@ 2009-07-27 17:52 longb at cray dot com
  2009-07-27 22:47 ` [Bug fortran/40876] " jakub at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: longb at cray dot com @ 2009-07-27 17:52 UTC (permalink / raw)
  To: gcc-bugs

Beginning with the OpenMP API Version 2.5, this case should fail at
compile-time.  The gfortran compiler does not reject this case, but gets a
segmentation fault at run-time.

The OpenMP API Version 3.0 (May 2008) lists the following restriction to a
private clause on p 91. lines 29-30:

" * Variables that appear in ... expressions for statement function
definitions, may not appear in a private clause."

Test case:

> cat ISU3136.f90
! derived from OpenMP test omp1/F2_6_2_1_2a.f90
!     According to OpenMP API Ver 2.5 May 2005 p. 75 lines 19/20
!     this is a negative test that should fail at compile-time.
      use omp_lib
      implicit none
      integer, parameter :: NT = 4
      integer :: nThreads(NT)
      integer :: a, st_func, i
      st_func() = a + 1

!$    call omp_set_dynamic(.false.)
!$    call omp_set_num_threads(NT)

!$omp parallel private(a)
      a = omp_get_thread_num()
!$omp barrier
      nThreads(omp_get_thread_num()+1) = st_func()
!$omp end parallel

      do i = 1, NT
          if(nThreads(i) /= i) then
              print*, 'FAIL: non-private copy is used in a statement function.'
          endif
      enddo

      END

> ftn -o x -fopenmp ISU3136.f90
> aprun -n 1 ./x
Application 1190869 exit signals: Segmentation fault
Application 1190869 resources: utime 0, stime 0

Expected output (using the Cray compiler) with a compile-time message:

> module swap PrgEnv-gnu PrgEnv-cray
> ftn -o x -h omp ISU3136.f90

!$omp parallel private(a)
                       ^  
ftn-1760 crayftn: ERROR $MAIN, File = ISU3136.f90, Line = 14, Column = 24 
  "A" is referenced in a statement function expression, so it must not be
specified in the PRIVATE, FIRSTPRIVATE or LASTPRIVATE clause.


-- 
           Summary: OpenMP private variable referenced in a statement
                    function
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: longb at cray dot com
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40876


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-10-26 15:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40876-4@http.gcc.gnu.org/bugzilla/>
2010-12-27  1:40 ` [Bug fortran/40876] OpenMP private variable referenced in a statement function dfranke at gcc dot gnu.org
2010-12-27  1:42 ` longb at cray dot com
2020-10-26 15:57 ` longb at cray dot com
2009-07-27 17:52 [Bug fortran/40876] New: " longb at cray dot com
2009-07-27 22:47 ` [Bug fortran/40876] " jakub at gcc dot gnu dot org
2009-07-28 12:21 ` jakub at gcc dot gnu dot org
2009-07-28 13:47 ` longb at cray dot com
2009-07-28 14:35 ` jv244 at cam dot ac dot uk
2009-07-28 14:43 ` burnus at gcc dot gnu dot org
2009-11-13 22:20 ` longb at cray dot com
2010-05-07 19:50 ` dfranke at gcc dot gnu dot org
2010-05-07 22:06 ` longb at cray dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).