public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pmblakely at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/111719] New: Omitting data-sharing attribute for function return value in OpenMP does not raise an error.
Date: Sat, 07 Oct 2023 13:13:18 +0000	[thread overview]
Message-ID: <bug-111719-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111719
           Summary: Omitting data-sharing attribute for function return
                    value in OpenMP does not raise an error.
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pmblakely at googlemail dot com
  Target Milestone: ---

In the following Fortran90 example:

program prog

contains
  function b(arr)
    implicit none
    integer :: i, xCells
    real(kind = 8) :: dx, a, dc, b, dt
    real(kind = 8), allocatable, dimension(:), intent(in) :: arr

    b = 1d300
    dc = 1d300
!$OMP parallel do default(none) reduction(min:dt) firstprivate(xCells, dx, a)
shared(arr)
    do i = 0, xCells 
       a = arr(i)
       b = min(b, 1d0 / a)
    end do                                                                      
  end function b
end program prog

the return value for function 'b' is the intended reduction value in the
do-loop, but is not mentioned in the OpenMP reduction clause (dt is incorrectly
mentioned instead). Due to the default(none) clause, this should be a
compile-time error.
However:
gfortran test.f90 -o test -fopenmp
compiles this without warnings or errors (versions 13.1.0, 8.4.0, 9.4.0, 11.2.0
and 12.1.0 all tested).

If "b = min(b, 1d0 / a)" is replaced by "dc = min(dc, 1d0/a)"
then gfortran gives: "Error: 'dc' not specified in enclosing ‘parallel’"

I would expect this error to be generated in the original case as well.

Note that the OpenMP standard at
https://www.openmp.org/spec-html/5.2/openmpsu33.html does not give an
implicitly determined data-sharing attribute for the function return value.
Also the Intel Fortran ifort (2021.8.0) does raise the expected error on the
above test-code.

                 reply	other threads:[~2023-10-07 13:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111719-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).