public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/113975] New: function returning array is not fully evaluated before assignement
@ 2024-02-17 19:36 comptes at ugo235 dot fr
  2024-02-17 20:21 ` [Bug fortran/113975] " anlauf at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: comptes at ugo235 dot fr @ 2024-02-17 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113975
           Summary: function returning array is not fully evaluated before
                    assignement
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: comptes at ugo235 dot fr
  Target Milestone: ---

The following code is poorly designed, yet I think it is standard-conforming:
======================================
module foo
implicit none
    integer, parameter :: n=3
    integer :: a(n,n)
contains
    pure function bar()
    integer :: bar(n,n)
    bar = transpose(a)
    end function bar
end module foo

program main
use foo
implicit none
integer :: i

a = reshape([ 11, 12, 13 &
            , 21, 22, 23 &
            , 31, 32, 33 ], shape=[n,n], order=[2,1] )

a = bar()

do i = 1, n
    print*, a(i,:)
end do

end program main
======================================

In `a = bar()`, `bar()` should be fully evaluated before the result is assigned
to `a`, and it seems this is not the case. Consequently, the output of the
program compiled with gfortran 13.2 (without any option) is not the transpose
of the matrix that is entered in the code:

======================================
Program returned: 0
Program stdout

          11          12          13
          12          22          23
          13          23          33
======================================

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

* [Bug fortran/113975] function returning array is not fully evaluated before assignement
  2024-02-17 19:36 [Bug fortran/113975] New: function returning array is not fully evaluated before assignement comptes at ugo235 dot fr
@ 2024-02-17 20:21 ` anlauf at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-02-17 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.  See also PR113892.

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

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

end of thread, other threads:[~2024-02-17 20:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-17 19:36 [Bug fortran/113975] New: function returning array is not fully evaluated before assignement comptes at ugo235 dot fr
2024-02-17 20:21 ` [Bug fortran/113975] " 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).