I just encountered a rather strange bug in gfortran. Consider the following
code:

implicit none         
type particle
  integer :: ID
end type
type(particle), dimension(1,1:3)  :: finalState
finalstate(1,(/1:2/))%ID = (/1,103/) 
end

This is compiled fine with ifort and pgf95, but gfortran 4.5 trunk says:

  finalstate(1,(/1:2/))%ID = (/1,103/) 
       1                               
Error: FINAL declaration at (1) must be inside a derived type CONTAINS section

This is very funny. Seems like the first part of the variable name is
interpreted as a FINAL declaration. We should at least make sure the FINAL
keyword is separated by spaces when parsing stuff like this. This error message
appears on trunk and 4.4.


Btw gfortran 4.3 and g95 say:

finalstate(1,(/1:2/))%ID = (/1,103/)
               1
Error: Syntax error in array constructor at (1)


And sunf95's opinion is:

finalstate(1,(/1:2/))%ID = (/1,103/)
                ^
"test.f90", Line = 7, Column = 17: ERROR: Unexpected syntax: "/)" was expected
but found ":".


With so many compilers rejecting it, I wonder: Is it actually legal?


-- 
           Summary: statement misinterpreted as FINAL declaration
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43244

Reply via email to