This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/68218] ALLOCATE with size given by a module function


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

Harald Anlauf <anlauf at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gmx dot de

--- Comment #2 from Harald Anlauf <anlauf at gmx dot de> ---
This jewel is really funny.

Extending the testcase in comment #0:

MODULE mo_test
  implicit none
  integer :: n = 0
CONTAINS
  FUNCTION nquery()
    INTEGER :: nquery
    n = n + 1
    WRITE (0,*) "hello #", n
    nquery = n
  END FUNCTION nquery
END MODULE mo_test
! ----------------------------------------------------------------------
! MAIN PROGRAM
! ----------------------------------------------------------------------
PROGRAM example
  USE mo_test
  implicit none
  INTEGER, ALLOCATABLE :: query_buf(:)
  ALLOCATE(query_buf(nquery()))
  print *, "n, size (query_buf) =", n, size (query_buf)
  if (n /= 1 .or. size (query_buf) /= n) print *, "ERROR!"
END PROGRAM example


one finds:

4.3, 4.6:

 hello #           1
 hello #           2
 hello #           3
 hello #           4
 n, size (query_buf) =           4           1
 ERROR!

4.7 and newer:

 hello #           1
 hello #           2
 hello #           3
 hello #           4
 n, size (query_buf) =           4           4
 ERROR!


Looking at the dump tree, there is no temporary generated for the function
result.

If one was interested only in the size of query_buf, this would be technically
a regression...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]