diff mbox

PR fortran/66942 -- avoid referencing a NULL C++ thing

Message ID 20150729164552.GA12035@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl July 29, 2015, 4:45 p.m. UTC
On Wed, Jul 29, 2015 at 02:04:12PM +0200, Richard Biener wrote:
> On Wed, Jul 29, 2015 at 1:59 PM, Mikael Morin <mikael.morin@sfr.fr> wrote:
> > Le 29/07/2015 13:22, Richard Biener a écrit :
> >>
> >> On Wed, Jul 29, 2015 at 11:34 AM, Mikael Morin <mikael.morin@sfr.fr>
> >> wrote:
> >>>
> >>> Le 29/07/2015 10:26, Richard Biener a écrit :
> >>>>>>
> >>>>>>
> >>>>>> Did you try using vec_safe_splice?
> >>>>
> >>>>
> >>>>
> >>>> That handles NULL retargs, not NULL or empty arglist.
> >>>>
> >>> I think retargs is NULL.
> >>
> >>
> >> Not if the patch fixes anything.
> >>
> > The case retargs == NULL is the case arglen == 0, which means every vector
> > pointer we are about to splice is NULL.
> > So the patch fixes it.
> 
> Ok, that wasn't obvious from reading the patch.
> 

This builds and passes regression testing on x86_64-*-freebsd.
OP found the problem by running the sanatizers.  I don't
know how to build gcc with this as a build option.  I'll
commit whichever diff you recommend.

Comments

Mikael Morin July 30, 2015, 2:08 p.m. UTC | #1
Le 29/07/2015 18:45, Steve Kargl a écrit :
> On Wed, Jul 29, 2015 at 02:04:12PM +0200, Richard Biener wrote:
>> On Wed, Jul 29, 2015 at 1:59 PM, Mikael Morin <mikael.morin@sfr.fr> wrote:
>>> Le 29/07/2015 13:22, Richard Biener a écrit :
>>>>
>>>> On Wed, Jul 29, 2015 at 11:34 AM, Mikael Morin <mikael.morin@sfr.fr>
>>>> wrote:
>>>>>
>>>>> Le 29/07/2015 10:26, Richard Biener a écrit :
>>>>>>>>
>>>>>>>>
>>>>>>>> Did you try using vec_safe_splice?
>>>>>>
>>>>>>
>>>>>>
>>>>>> That handles NULL retargs, not NULL or empty arglist.
>>>>>>
>>>>> I think retargs is NULL.
>>>>
>>>>
>>>> Not if the patch fixes anything.
>>>>
>>> The case retargs == NULL is the case arglen == 0, which means every vector
>>> pointer we are about to splice is NULL.
>>> So the patch fixes it.
>>
>> Ok, that wasn't obvious from reading the patch.
>>
>
> This builds and passes regression testing on x86_64-*-freebsd.
> OP found the problem by running the sanatizers.  I don't
> know how to build gcc with this as a build option.  I'll
> commit whichever diff you recommend.
>
I prefer this second variant.
OK for trunk without further comment from Richi.
Thanks.

Mikael
Steve Kargl Aug. 3, 2015, 4:57 p.m. UTC | #2
On Thu, Jul 30, 2015 at 04:08:47PM +0200, Mikael Morin wrote:
> Le 29/07/2015 18:45, Steve Kargl a écrit :
> >
> > This builds and passes regression testing on x86_64-*-freebsd.
> > OP found the problem by running the sanatizers.  I don't
> > know how to build gcc with this as a build option.  I'll
> > commit whichever diff you recommend.
> >
> I prefer this second variant.
> OK for trunk without further comment from Richi.
> Thanks.
> 

Thanks Mikael.  Committed revision 226517.
diff mbox

Patch

Index: trans-expr.c
===================================================================
--- trans-expr.c	(revision 226328)
+++ trans-expr.c	(working copy)
@@ -5921,18 +5921,18 @@  gfc_conv_procedure_call (gfc_se * se, gf
   vec_safe_reserve (retargs, arglen);
 
   /* Add the return arguments.  */
-  retargs->splice (arglist);
+  vec_safe_splice (retargs, arglist);
 
   /* Add the hidden present status for optional+value to the arguments.  */
-  retargs->splice (optionalargs);
+  vec_safe_splice (retargs, optionalargs);
 
   /* Add the hidden string length parameters to the arguments.  */
-  retargs->splice (stringargs);
+  vec_safe_splice (retargs, stringargs);
 
   /* We may want to append extra arguments here.  This is used e.g. for
      calls to libgfortran_matmul_??, which need extra information.  */
-  if (!vec_safe_is_empty (append_args))
-    retargs->splice (append_args);
+  vec_safe_splice (retargs, append_args);
+
   arglist = retargs;
 
   /* Generate the actual call.  */