This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/15335] [gfortran] runtime error "Attempt to allocate a non-positive amount of memory"
- From: "Tobias dot Schlueter at physik dot uni-muenchen dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 May 2004 11:31:45 -0000
- Subject: [Bug fortran/15335] [gfortran] runtime error "Attempt to allocate a non-positive amount of memory"
- References: <20040507002755.15335.Tobias.Schlueter@physik.uni-muenchen.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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