This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] Always return malloc(1) for empty arrays in the library
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Jun 2011 20:09:55 +0200
- Subject: Re: [patch, fortran] Always return malloc(1) for empty arrays in the library
- References: <4E0A4C94.7030602@netcologne.de> <BANLkTi=Os1y_XFJrjX1T10tU6f5YSXKDsA@mail.gmail.com>
Hi Janne,
I'd prefer to add the zero check to runtime/memory.c
(internal_malloc_size), i.e. change
if (size == 0)
return NULL;
to
if (size == 0)
size = 1;
Good point. I have done so in the attached patch, plus removed
all special cases for checking for zero size.
Regression-tested. OK for trunk?
For 4.6, I would just commit the change to internal_malloc_size
(which would also fix PR 49479), plus the test case for that
PR.
OK?
Regards
Thomas