This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR26197 (new_type_alias) fix
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Dorit Nuzman <DORIT at il dot ibm dot com>, gcc-patches at gcc dot gnu dot org, Diego Novillo <dnovillo at redhat dot com>
- Date: Tue, 08 Aug 2006 15:02:49 -0400
- Subject: Re: PR26197 (new_type_alias) fix
- References: <OF8DEC1963.5AEB77BD-ONC22571B5.006A136D-C22571B5.006C66DE@il.ibm.com> <m3d5bbfel1.fsf@localhost.localdomain>
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