https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87233
Bug ID: 87233 Summary: Constraint C1279 still followed after f2008 standard revision (?) Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: juergen.reuter at desy dot de Target Milestone: --- this is a question on the constraint C1279 from J3/04-007 "In the scoping unit of an elemental subprogram, an object designator with a dummy argument as the base object shall not appear in a specification-expr except as the argument to one of the intrinsic functions BIT_SIZE, KIND, LEN, or the numeric inquiry functions (13.5.6)." It seems that this restriction was removed for the Fortran 2008 standard (J3/10-007) gfortran still conforms to -std=f2003 here and disallows this even with the flag -std=f2008? Isn't this incorrect behaviour? IMHO the following program below would be conformant to f2008. Intel seems to accept this (while nagfor also vetoes for the same reason obviously): https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-and-reference-elemental Cheers, JRR module m implicit none private type, public :: string_t private character(len=:), allocatable :: cs contains private procedure, pass(self) :: get_substr_pos procedure, pass(self) :: get_substr_pos_len procedure, pass(self) :: assign_t procedure, pass(self), public :: length => string_len generic, public :: assignment(=) => assign_t generic, public :: substr => get_substr_pos, get_substr_pos_len end type string_t contains elemental function string_len(self) result(l) class(string_t), intent(in) :: self ! Function result integer :: l l = len(self%cs) end function string_len elemental subroutine assign_t(self, cs) class(string_t), intent(inout) :: self character(len=*), intent(in) :: cs self%cs = cs end subroutine assign_t elemental function get_substr_pos( self, pos ) result( substr ) ! Argument list class(string_t), intent(in) :: self integer, intent(in) :: pos ! Function result character(len=len(self%cs)-pos+1) :: substr ! checks elided substr = self%cs(pos:) return end function get_substr_pos elemental function get_substr_pos_len( self, pos, slen ) result( substr ) ! Argument list class(string_t), intent(in) :: self integer, intent(in) :: pos integer, intent(in) :: slen ! Function result character(len=slen) :: substr ! checks elided substr = self%cs(pos:(pos+slen-1)) return end function get_substr_pos_len end module m program assign_overlap use m, only : string_t implicit none type(string_t) :: str str = '0123456789' print *, '"'//str%substr( pos=1 )//'"' str = str%substr( pos=1, slen=5 ) print *, '"'//str%substr( pos=1 )//'"' stop end program assign_overlap