(j3.2006) finalizing undefined entities -- odd text in 6.6.4
Bill Long
longb
Wed Mar 19 19:08:24 EDT 2008
Robert Corbett wrote:
>
> I ran the following syntactically modified program using Sun Fortran:
>
> PROGRAM MAIN
> POINTER A, B
>
> ALLOCATE(A)
> B => A
> DEALLOCATE(B, STAT=I1)
> DEALLOCATE(A, STAT=I2)
> PRINT *, I1, I2
> END
>
> The output of the program is
>
> 0 1185
>
> The error message assciated with error code 1185 is
>
> Error 1185: deallocating an object not allocated by an ALLOCATE
> statement
>
> The error message might be a bit confusing, but it is accurate. After
> the first DEALLOCATE statement, the object is no longer allocated, and
> so it is not allocated by an ALLOCATE statement.
>
> Nonetheless, I agree with your basic point. After the first DEALLOCATE
> statement, the target pointer allocation status of A is undefined.
> Therefore, the second DEALLOCATE statement violates the requirement of
> the first sentence of Section 6.3.3.2 of the Fortran 2003 standard.
> Therefore, the program is not a standard-conforming program, and any
> behavior whatever is permitted.
>
>
I agree. The second sentence of the same section spells out the cases
that cause an error condition in the deallocate statement. Having the
pointer association status undefined is not one of them. Thus, an
implementation could make an argument for returning stat= of 0 for the
second deallocate above. Sun's action is also allowed, and perhaps more
informative.
Cheers,
Bill
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list