This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Bug 78640 - [F2015] gfortran accepts invalid allocatable polymorphic result in pure function
- From: Damian Rouson <damian at sourceryinstitute dot org>
- To: gfortran <fortran at gcc dot gnu dot org>
- Date: Thu, 1 Dec 2016 16:39:24 -0800
- Subject: Bug 78640 - [F2015] gfortran accepts invalid allocatable polymorphic result in pure function
- Authentication-results: sourceware.org; auth=none
All,
I just submitted the text below as PR 78640.
Damian
Constraint C1589 in Draft 16-007r2 of the Fortran 2015 standard states
"A pure function shall not have a polymorphic allocatable result."
As demonstrated below, a 20161127 build of gfortran 7.0.0 accepts code that violates the above constraint:
$ cat poly-alloc-result.f90
type foo
end type
type(foo) :: bar
bar = f()
contains
pure function f() result(y)
class(foo), allocatable :: y
allocate(foo::y)
end function
end
$ gfortran poly-alloc-result.f90
$ ./a.out
$ gfortran --version
GNU Fortran (MacPorts gcc7 7-20161127_0) 7.0.0 20161127 (experimental)