PR26197 (new_type_alias) fix

Daniel Berlin dberlin@dberlin.org
Tue Aug 8 21:11:00 GMT 2006


Ian Lance Taylor wrote:
> Dorit Nuzman <DORIT@il.ibm.com> writes:
> 
>> Index: tree-ssa-alias.c
>> ===================================================================
>> *** tree-ssa-alias.c	(revision 115685)
>> --- tree-ssa-alias.c	(working copy)
>> *************** static void create_global_var (void);
>> *** 114,119 ****
>> --- 114,120 ----
>>   static void maybe_create_global_var (struct alias_info *ai);
>>   static void group_aliases (struct alias_info *);
>>   static void set_pt_anything (tree ptr);
>> + static tree add_may_alias_for_new_tag (tree tag, tree var);
>>   
>>   /* Global declarations.  */
> 
> The current gcc convention is to define static functions before their
> use, where possible, and to not bother with an explicit declaration.
> That is, you should omit this declaration, and move the definition of
> add_may_alias_for_new_tag before new_type_alias.
> 
> 
>> +   ref = get_ref_base_and_extent (expr, &offset, &size, &maxsize);
>> +   if (ref == NULL_TREE)
>> +     ref = var;
> 
> Here you allow for the possibility that EXPR does not have a base and
> extent which can be determined.

Which is true.

> 
>>         for (sv = svars; sv; sv = sv->next)
>>   	{
>> !           bool exact;
>>   
>> !           if (overlap_subvar (offset, maxsize, sv->var, &exact))
>> !             VEC_safe_push (tree, heap, overlaps, sv->var);
>> !         }
> 
> Here you seem to assume that OFFSET and MAXSIZE will always be set
> correctly.  It seems to me that in the case where
> get_ref_base_and_extent returns NULL_TREE, then OFFSET and MAXSIZE
> will be such that overlap_subvar will always return false. 

Which is false.
if get_ref_base_and_extent returns NULL_TREE, offset will always be 0,
and maxsize/pmaxsize will be -1.

Anyway given the inputs to get_ref_base_and_extent she is using, you can
assert non-nullness of the result. It can't return NULL if you give it a
valid var or component ref, AFAICT.

We certainly assume this in other uses.
--Dan



More information about the Gcc-patches mailing list