Re: [Patch, Fortran] PR53521 - Fix size == 0 handling with reallocate

2012-05-31 Thread Janne Blomqvist
On Thu, May 31, 2012 at 12:28 PM, Tobias Burnus wrote: > Dear all, > > gfortran was producing the following code: > >  res = realloc (mem, size) >  if (size == 0) >    res = NULL; >  ... >  if (res != 0) >    free (res) > > The problem is that "realloc (..., 0)" does not have to produce a NULL > p

Re: [Patch, Fortran] PR53521 - Fix size == 0 handling with reallocate

2012-05-31 Thread Jakub Jelinek
On Thu, May 31, 2012 at 11:28:20AM +0200, Tobias Burnus wrote: > I see two possibilities: > > > 1) FIRST approach: manual freeing/NULL setting; that's the closed > what is currently done. (Note: It calls free unconditionally; > "free(0)" is optimized away by the middle end. > (Note: That requires

[Patch, Fortran] PR53521 - Fix size == 0 handling with reallocate

2012-05-31 Thread Tobias Burnus
Dear all, gfortran was producing the following code: res = realloc (mem, size) if (size == 0) res = NULL; ... if (res != 0) free (res) The problem is that "realloc (..., 0)" does not have to produce a NULL pointer as result. While in "valgrind" one only gets the warning that