This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch] Fix fortran/25031, multiple allocations
On Wed, Mar 01, 2006 at 06:03:26PM -0800, Brooks Moses wrote:
> Steve Kargl wrote:
> >On Wed, Mar 01, 2006 at 09:40:22PM +0100, Thomas Koenig wrote:
> >>here is a fix for PR 25031. The problem here was that we used
> >>to be capable of allocating an allocatable array twice without
> >>intermediate deallocation, which should raise an error.
> >
> >Are you saying that this program should fail?
> >
> >program a
> > real, allocatable :: x(:)
> > allocate(x(4))
> > allocate(x(3))
> >end program a
>
> F95 Draft Standard, 6.3.1.1: "An allocatable array that has been
> allocated by an ALLOCATE statement and has not been subsequently
> deallocated (6.3.3) is *currently allocated* and is definable.
> Allocating a currently allocated allocatable array causes an error
> condition in the ALLOCATE statement." (emphasis in original)
>
So? An "error condition" does not mean that the program fails.
It means that if one had used STAT=, then one can determine if
an "error condition" occurred. AFAICT, the Standard does not
prohibit a memory leak. NAG's compiler compiles the above and
Lahey's web based checker also compiles the code.
--
Steve