------- Comment #4 from rguenth at gcc dot gnu dot org  2010-02-05 14:23 -------
(In reply to comment #3)
> Subject: Re:  Weird temporary array allocation
> 
> On Fri, 5 Feb 2010, pault at gcc dot gnu dot org wrote:
> 
> > ------- Comment #2 from pault at gcc dot gnu dot org  2010-02-05 05:36 
> > -------
> > (In reply to comment #1)
> > 
> > > Why there is a negative check? Well, I do not know. I also can speculate 
> > > about
> > > a poor man's overflow check, which sometimes indeed works, but often 
> > > fails.
> > 
> > I suspect that you are being generous and that this is rather a sin of 
> > omission
> > rather than commission.
> > 
> > 
> > > Paul, what do you think?
> > 
> > I think that your arguments are correct.
> > 
> > > 
> > > (PS: POSIX Allows "ptr = malloc(0); free(ptr)", where "malloc(0)" returns
> > > either NULL or a unique pointer.)
> > 
> > Indeed.
> 
> Btw, should there be the same error reporting or if (allocated) behavior
> on Frontend-generated temporaries?  I see this from the temporaries
> generated by the scalarizer and the introduced control-flow makes it
> very hard to remove unnecessary temporaries in the middle-end later.

Thus, basically adding an argument to gfc_call_malloc () specifying
whether we want to do checking at all and shortcut it from at least
gfc_trans_allocate_array_storage ().


-- 


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

Reply via email to