This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, c++ diagnostics] Fix c++ front end i18n problems


Hi,
> On 12/10/2009 07:34 PM, Paolo Bonzini wrote:
>> You still have memory leaks.  Also, the condition "fns == NULL_TREE
>> && !TREE_VALUE (fns)" is wrong as the second part of the "&&" will
>> always cause a segfault when evaluated.
>>
>>> +  /* Only if all the candidates are covered,
>>> +     the spaces can be freed.  */
>>> +  if (spaces
>>> +      && fns == NULL_TREE
>>> +      && !TREE_VALUE (fns))
>>> +    {
>>> +       *str = NULL;
>>> +       free (spaces);
>>> +    }
>>
>>   if (!spaces)
>>     {
>>       /* String owned by the owner, it should not be freed.  */
>>       *str = NULL;
>>     }
>
> In order to print " "<repeat n times> from the second candidate at
>
> error ("%s %+#D", *str, OVL_CURRENT (fn));
>
> The *str is changed at print_overloaded_functions first. When the
> OVL_NEXT loop is over, and back to print_chained_functions, call
> print_overloaded_functions will transfer " "<repeat n times> to
> print_overloaded_functions. That is also why the argument of
> print_overloaded_functions is **str not *str.
> Since the pointer spaces and *str point the same place after assign
> spaces to *str, *str can't be assign NULL. Otherwise it will produce
> "segment fault".
I'm wondering if it would make sense to simplify this business like
this: first, at the beginning of print_candidates we walk fns and
construct a new linearized list containing all the candidates which must
be printed, then we print it. Surely we are wasting some memory, but I
bet things would become much cleaner. I don't think performance is an
issue, in this code path. Eventually, I think we want to understand why
in some cases the list of overloads contains TREE_LISTs (c++/35112),
that seems indeed strange, but probably should be done later, in Stage1...

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]