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

[Bug fortran/77391] New: gfortran allows CHARACTER(LEN=:),PARAMETER:: STRING='constant' buts does not report it as an extension


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

            Bug ID: 77391
           Summary: gfortran allows CHARACTER(LEN=:),PARAMETER::
                    STRING='constant'   buts does not report it as an
                    extension
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: urbanjost at comcast dot net
  Target Milestone: ---

Created attachment 39501
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39501&action=edit
test script with code and output

gfortran allows length of ":" on character parameter values; which appears to
be an extension of the standard. I would prefer that the extension either not
be allowed or be warned about to support code portability.

DETAILS:

 It appears that gfortran has an extension that is not reported when
-std=2008 is used.  Other compilers fail and complain when a colon
is used for the length when declaring a character variable with the
parameter attribute.

For instance, the Intel ifort compiler (version 16.1) complains:

error #8238: A colon may be used as a type parameter value only in the
declaration of an entity or component that has the POINTER or ALLOCATABLE
attribute.

Which appears to be a quote from the f2008 standard, 4.2.6.

6 A type parameter value may be specified by a type specification (4.4, 4.5.9).

  R401       type-param-value             is scalar-int-expr
                                          or *
                                          or :

  C401       (R401) The type-param-value for a kind type parameter shall be an
initialization expression.

  C402       (R401) A colon shall not be used as a type-param-value except in
the declaration of an entity or component
             that has the POINTER or ALLOCATABLE attribute.

Example code:

program picky
character(len=*),parameter :: ident1="@(#)one(3f): with asterisk"
character(len=:),parameter :: ident2="@(#)two(3f): with colon, which appears to
be an extension?"
write(*,*)ident1
write(*,*)ident2
end program picky

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