public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jfeng33 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/106948] New: pure subroutine with pure procedure as dummy
Date: Thu, 15 Sep 2022 01:44:07 +0000	[thread overview]
Message-ID: <bug-106948-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 106948
           Summary: pure subroutine with pure procedure as dummy
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jfeng33 at hotmail dot com
  Target Milestone: ---

Compiling the below code failed and gave the following error in which f was
declared to be pure:

   22 |     x = int(f(real(x)) * 0.1)
      |             1
Error: Reference to impure function ‘f’ at (1) within a PURE procedure



module a
  implicit none

  interface new
    pure module subroutine b(x, f)
      integer, intent(inout) :: x
      interface
        pure function f(x) result(r)
          real, intent(in) :: x
          real :: r
        end function f
      end interface
    end subroutine b
  end interface new
end module a

submodule(a) a_b
  implicit none

contains
  module procedure b
    x = int(f(real(x)) * 0.1)
  end procedure b
end submodule a_b


program test
  use a
  implicit none

  integer :: x

  x = 10
  call new(x, g)
  print *, x

contains

  pure function g(y) result(r)
    real, intent(in) :: y
    real :: r

    r = sqrt(y)
  end function g
end program test

             reply	other threads:[~2022-09-15  1:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  1:44 jfeng33 at hotmail dot com [this message]
2022-09-15 18:44 ` [Bug fortran/106948] " anlauf at gcc dot gnu.org

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-106948-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).