public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified
@ 2021-03-15 23:09 Boyce at engineer dot com
  2021-03-16  0:34 ` [Bug fortran/99609] " kargl at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Boyce at engineer dot com @ 2021-03-15 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99609
           Summary: Pure Function that has a Variable with Value Attribute
                    that is modified
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Boyce at engineer dot com
  Target Milestone: ---

Created attachment 50392
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50392&action=edit
Module that replicates the error

This is a problem I found in all versions of gfortran.

The issue is with the value attribute for a pure function raises an error if
the variable is changed. gfortran assumes that the variable has an intent(in),
but with the value attribute the variable is a copy so the original is not
changed.

For example, the following module raises an error for func1, but not func2.
Functionally the two functions are equivalent, but one explicitly declares the
copy of a.

The attachment contains the same code as the following, but with a PROGRAM/END
PROGRAM driver.

MODULE ex_func
  contains
  !
  ! Does not recognize that value makes a copy of "a"
  !
  pure function func1(a) result(x)
    integer, value :: a
    integer :: x
    !
    a = a*a
    !
    x = a
    !
  end function
  !
  pure function func2(a) result(x)
    integer, intent(in) :: a
    integer :: x
    integer :: tmp
    !
    tmp = a
    tmp = tmp*tmp
    !
    x = tmp
    !
  end function
END MODULE

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

* [Bug fortran/99609] Pure Function that has a Variable with Value Attribute that is modified
  2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
@ 2021-03-16  0:34 ` kargl at gcc dot gnu.org
  2021-03-16 13:16 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-03-16  0:34 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org
           Priority|P3                          |P4

--- Comment #1 from kargl at gcc dot gnu.org ---
Seems to fixed on main (aka 11.0.1).  Not sure if anyone did or will backport
the fix to the 10 or older branch.

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

* [Bug fortran/99609] Pure Function that has a Variable with Value Attribute that is modified
  2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
  2021-03-16  0:34 ` [Bug fortran/99609] " kargl at gcc dot gnu.org
@ 2021-03-16 13:16 ` burnus at gcc dot gnu.org
  2021-03-18  3:22 ` Boyce at engineer dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-03-16 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
I believe this is a duplicate of PR fortran/97491, which has been fixed on
mainline (upcoming GCC 11) and also on the GCC 10 branch.

*** This bug has been marked as a duplicate of bug 97491 ***

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

* [Bug fortran/99609] Pure Function that has a Variable with Value Attribute that is modified
  2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
  2021-03-16  0:34 ` [Bug fortran/99609] " kargl at gcc dot gnu.org
  2021-03-16 13:16 ` burnus at gcc dot gnu.org
@ 2021-03-18  3:22 ` Boyce at engineer dot com
  2021-03-18  3:28 ` jvdelisle at gcc dot gnu.org
  2021-03-18 21:20 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: Boyce at engineer dot com @ 2021-03-18  3:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Scott Boyce <Boyce at engineer dot com> ---
Yeah that is the same bug request. Though it is for version 11, any chance of
back-porting to version 9 and 10?

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

* [Bug fortran/99609] Pure Function that has a Variable with Value Attribute that is modified
  2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
                   ` (2 preceding siblings ...)
  2021-03-18  3:22 ` Boyce at engineer dot com
@ 2021-03-18  3:28 ` jvdelisle at gcc dot gnu.org
  2021-03-18 21:20 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2021-03-18  3:28 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Scott Boyce from comment #3)
> Yeah that is the same bug request. Though it is for version 11, any chance
> of back-porting to version 9 and 10?

It has been committed to version 10.

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

* [Bug fortran/99609] Pure Function that has a Variable with Value Attribute that is modified
  2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
                   ` (3 preceding siblings ...)
  2021-03-18  3:28 ` jvdelisle at gcc dot gnu.org
@ 2021-03-18 21:20 ` anlauf at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-03-18 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #5 from anlauf at gcc dot gnu.org ---
The patch for pr97491 appears simple and safe.  I could check if a "backport"
works unless there are objections.

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

end of thread, other threads:[~2021-03-18 21:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 23:09 [Bug fortran/99609] New: Pure Function that has a Variable with Value Attribute that is modified Boyce at engineer dot com
2021-03-16  0:34 ` [Bug fortran/99609] " kargl at gcc dot gnu.org
2021-03-16 13:16 ` burnus at gcc dot gnu.org
2021-03-18  3:22 ` Boyce at engineer dot com
2021-03-18  3:28 ` jvdelisle at gcc dot gnu.org
2021-03-18 21:20 ` anlauf at gcc dot gnu.org

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