[Bug fortran/83939] New: Constraint C1290 (elemental function cannot be allocatable) not enforced

vladimir.fuka at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 19 10:14:00 GMT 2018


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

            Bug ID: 83939
           Summary: Constraint C1290 (elemental function cannot be
                    allocatable) not enforced
           Product: gcc
           Version: 7.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vladimir.fuka at gmail dot com
  Target Milestone: ---

Based on report
https://stackoverflow.com/questions/48331223/fortran-elemental-function-is-this-behavior-normal
. The following code is illegal Fortran 2008, but compiles cleanly:

elemental function f() result(s)
  allocatable s
  allocate(s)
  s = 3.5
end function

gfortran-7 -c -Wall -Wextra -Wsurprising allocelem.f90




If the `result()` clause is not used, the constraint is caught:

elemental function s()! result(s)
  allocatable s
  allocate(s)
  s = 3.5
end function

> gfortran-7 -c -Wall -Wextra -Wsurprising allocelem.f90 
allocelem.f90:2:15:

   allocatable s
               1
Error: ALLOCATABLE attribute conflicts with ELEMENTAL attribute at (1)
allocelem.f90:3:11:

   allocate(s)
           1
Error: Allocate-object at (1) is neither a data pointer nor an allocatable
variable


More information about the Gcc-bugs mailing list