(j3.2006) implicit typing

Bill Long longb
Tue Aug 23 10:26:23 EDT 2016


Right.  I?ve tried multiple compilers and the error is consistently attached to the INTEGER C statement which attempts to declare C integer, conflicting with the REAL type previously established by implicit typing. 

Cheers,
Bill

On Aug 22, 2016, at 11:12 PM, Robert Corbett <robert.corbett at oracle.com> wrote:

> On 8/21/2016 10:14 AM, Bill Long wrote:
>> On Aug 20, 2016, at 8:05 AM, Robert Corbett <robert.corbett at oracle.com> wrote:
>> 
>>> Ian Harvey posted the following program to
>>> comp.lang.fortran.
>>> 
>>>    DIMENSION c(2)
>>>    PARAMETER(i=SIZE(c))
>>>    INTEGER c
>>>    END
>>> 
>>> He said none of the compilers he tried would compile
>>> the program, but that he failed to find s rule in
>>> the Fortran standard that it violated.  He pointed
>>> out that the definition of a constant expression does
>>> not include the restriction regarding agreement of
>>> implicit and explicit types that is given for
>>> specification expressions.
>> I?m not sure why that is relevant.
> 
> When Oracle Developer Studio Fortran is used to compile the
> code, the compiler does not detect an error on the PARAMETER
> statement.  It detects an error on the type declaration
> statement complaining that the type of the variable must be
> REAL.  My guess is that that is how the other compilers
> failed as well.
> 
> Bob Corbett
> 
>> The SIZE(c) reference does not depend on the type of C, only the shape, which was previously declared.  The question is wether the appearance of C as an argument to SIZE is sufficient to cause it to be implicitly typed as REAL,  which is then contradicted by the INTEGER declaration that comes later. As an experiment, try adding implicit none; integer i  at the beginning of the code.   If you still see an error about the type of C not being declared before C appears elsewhere, that is the issue.
> 
> The reported error is not that C is used before it is declared.
> The reported erroris that the type given to C by the explicit
> type declaration statement is not REAL.  Adding IMPLICIT NONE
> causes the compiler to report an addition error because the
> named constant i is not typed, but the message for the INTEGER
> statement differs only in the line number.
> 
> Bob Corbett
>> I have reduced sympathy for cases like this, since no respectable coding style guide would permit the use of either the DIMENSION or PARAMETER statements.
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list