This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Canonicalize &a to &a[0] during fold
On Mon, Apr 25, 2005 at 11:06:44AM +0200, Richard Guenther wrote:
> I would have come up with followups that also replace
> (a + i) with &a[i]. Should this also be fixed in the frontends?
No, this is fine for fold.
The problem with &a vs &a[0] is one of type. The front end is
broken wrt the type system. Plugging that hole would allow a
groddy special case to be removed from check_pointer_types_r:
if (!cpt_same_type (otype, dtype))
{
/* &array is allowed to produce a pointer to the element, rather than
a pointer to the array type. We must allow this in order to
properly represent assigning the address of an array in C into
pointer to the element type. */
gcc_assert (TREE_CODE (otype) == ARRAY_TYPE
&& POINTER_TYPE_P (ptype)
&& cpt_same_type (TREE_TYPE (otype), dtype));
break;
}
r~