[Bug fortran/35743] allocate negative memory for zero-sized WHERE construct
dominiq at lps dot ens dot fr
gcc-bugzilla@gcc.gnu.org
Mon Mar 31 15:15:00 GMT 2008
------- Comment #2 from dominiq at lps dot ens dot fr 2008-03-31 15:14 -------
The dump shows:
rg0025 (lda, nf1, nf2, nf3, nf5, nf6, mf1, mf2)
{
integer(kind=4) ubound.9;
...
D.979 = *nf6;
D.980 = *nf3;
D.981 = *nf6;
D.982 = *nf3;
D.983 = (1 - D.979) + *nf3;
num.12 = D.983;
D.986 = num.12;
if (D.986 < 0)
{
_gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
}
...
D.999 = *nf6;
D.1000 = *nf2;
D.1001 = *mf1;
D.1002 = *nf5;
D.1003 = *mf1;
atmp.19.dtype = 297;
atmp.19.dim[0].stride = 1;
atmp.19.dim[0].lbound = 0;
atmp.19.dim[0].ubound = *nf2 - D.999;
D.1014 = (*nf2 - D.999) + 1 <= 0;
D.1015 = (*nf2 - D.999) + 1;
D.1016 = D.1014 ? 0 : D.1015 * 4;
if (D.1016 < 0)
{
_gfortran_runtime_error (&"Attempt to allocate a negative amount of
memory."[1]{lb: 1 sz: 1});
}
...
}
The size
D.986 = num.12;
should have a check similar to
D.1016 = D.1014 ? 0 : D.1015 * 4;
in order to avoid the runtime error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35743
More information about the Gcc-bugs
mailing list