https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68218
Bug ID: 68218 Summary: ALLOCATE with size given by a module function Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ysheofue at imgof dot com Target Milestone: --- Calling ALLOCATE with an array size that is given by a function argument results in multiple calls of this function. This issue is present (at least) on gfortran versions 4.7 ... 5 The following program unintentionally calls "nquery()" four times: MODULE mo_test CONTAINS FUNCTION nquery() INTEGER :: nquery WRITE (0,*) "hello!" nquery = 1 END FUNCTION nquery END MODULE mo_test ! ---------------------------------------------------------------------- ! MAIN PROGRAM ! ---------------------------------------------------------------------- PROGRAM example USE mo_test INTEGER, ALLOCATABLE :: query_buf(:) ALLOCATE(query_buf(nquery())) END PROGRAM example