This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Constraint violation


It seems that gfortran has been violating a constraint, which has
been in the Fortran standard since at least F95.
!
! F95, 5.1.1.5, p. 51
!
! Constraint: The optional comma in a length-selector is permitted only
!             in a type-spec in a type-declaration-stmt.
!
! Constraint: The optional comma in a length-selector is permitted only if
!             no double colon separator appears in the type-declaration-stmt.
!
! F2003, 4.4.4.1, p. 41
!
! C419 (R425) The optional comma in a length-selector is permitted only in
!      a declaration-type-spec in a type-declaration-stmt.
!
! C420 (R425) The optional comma in a length-selector is permitted only if
!      no double-colon separator appears in the type-declaration-stmt.
!
! F2008, 4.4.3.2, p. 58
!
! C421 (R421) same as F2003:C419
! C422 (R421) same as F2003:C420
!
! F2015, 7.4.4.2, p. 66
!
! C725 (R722) same as F2003:C419
! C726 (R722) same as F2003:C420
!

gfortran accidentally catches the first constraint for each standard,
but it doesn't actually report the error.  Consider,

program foo
   character*2, parameter :: c(2) = [character*2, :: 'ab', 'cd']
   print *, c
end program foo

% gfortran6 -c c.f90
c.f90:2:50:

    character*2, parameter :: c(2) = [character*2, :: 'ab', 'cd']
                                                  1
Error: Syntax error in array constructor at (1)

This seems to be a side effect of r151023 (some 8 years, 3 months ago).

On the otherhand, gfortran seem to have never gotten the second
constraint correct.

program foo
   character*2, parameter :: c(2) = ['ab', 'cd']
   print *, c
end program foo

I have a patch that seems fixes the problem, but it reveals a number
of invalid testcases: arrayio_7.f90, assumed_charlen_function_4.f90,
char_initialiser_actual.f90, char_pointer_assign.f90, ichar_1.f90,
char_pointer_dependency.f90, char_pointer_dummy.f90, char_pointer_func.f90,
initialization_9.f90, pointer_check_6.f90, and read_eor.f90.

-- 
Steve


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