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/56174] New: Wrongly accepts "INTEGER :: b = HUGE(b)"


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

             Bug #: 56174
           Summary: Wrongly accepts "INTEGER :: b = HUGE(b)"
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


As reported at
https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/T9QQNONepKM


Using
  INTEGER, PARAMETER :: a(2) = (/ 1, 2 /), b = HUGE(b)
is invalid per the arguments given below.

Note, however, that
  INTEGER, PARAMETER :: a(2) = (/ 1, 2 /), b = HUGE(a)
is valid.

gfortran currently accepts it.


Fortran 2008 has in "7.1.12 Constant expression" (paragraph below C712):

"If a constant expression includes a specification inquiry that depends
on a type parameter or an array bound of an entity specified in the
same specication-part, the type parameter or array bound shall be
specified in a prior specification of the specification-part. The prior
specification may be to the left of the specification inquiry in the
same statement, but shall not be within the same entity-decl."


The latter is:

R503  entity-decl  is  object-name [( array-spec )]
                           [ lbracket coarray-spec rbracket ]
                           [ * char-length ] [ initialization ]
                    or  function-name [ * char-length ]

Thus, "object-name ... initialization" belongs to the same entry-decl.


"HUGE" belongs to the class "Inquiry function" and (cf. 7.1.11
Specification expression):

"A specification inquiry is a reference to
"(1) an intrinsic inquiry function, [...]"


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