This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] for PR 19333
Hello,
> On Mon, Jan 10, 2005 at 09:50:15AM +0100, Zdenek Dvorak wrote:
> > extern short ac[][];
>
> This makes no sense. Surely it's invalid C?
>
> Certainly *something* is missing in the front end, either via a
> diagnostic, or a cast. I cannot think of any reason you should
> have to deal with dereferencing incomplete types here. Or *was*
> there a cast and it got lost somehow?
as for validity of C -- I don't know. Gcc accepts it, however.
Note that we do not dereference incomplete type anywhere in the example --
everything is always casted to a suitable type. Assignment ac.33 = &ac
does not seem to need a cast, since (short [] *) and (short[][]) are
considered equivalent by STRIP_USELESS_TYPE_CONVERSION. (*ac.33)[0] is
fine - type of *ac.33 is (short []) and there is no problem with
indexing this. Once constant propagation is performed, you get
&(*&ac)[0], which has the discussed expression (*&ac) as a
subexpression, and it has maybe_fold_offset_to_array_ref called for it
during recursive simplification in fold_stmt_r.
Zdenek