[Bug fortran/15335] [gfortran] runtime error "Attempt to allocate a non-positive amount of memory"

Tobias dot Schlueter at physik dot uni-muenchen dot de gcc-bugzilla@gcc.gnu.org
Fri May 7 11:31:00 GMT 2004


------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de  2004-05-07 11:31 -------
Subject: Re:  [gfortran] runtime error  "Attempt to allocate
 a non-positive amount of memory"

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-07 03:55 -------
> So I do not know if the use of the uninitialized variable causing the problem, no it is not, I 
> initialized it to 1 and still got the error.
> 
No, this testcase is heavily reduced. This is the smallest I could get 
it without changing the error message. I didn't care about uninitialized 
variables. Indeed, this makes running valgrind kinda pointless :-/

> But I see that P(1: M - 1) is P(1: 0) when M is 1 (which is the first time through the loop) so 
> it is trying to allocating a size of 0 which causes the error. 

That's true. Reduced testcase:
	dimension a(1:4), b(1)
	i=1
	b = maxloc(a(1:i-1)+1.)
	end

The problem is that, when creating a temporary array, we don't check if 
it is actually of length zero.

- Tobi



-- 


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



More information about the Gcc-bugs mailing list