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: Further C front end tests


On Mon, 15 Nov 2004, Andreas Schwab wrote:

> "Joseph S. Myers" <joseph@codesourcery.com> writes:
> 
> > On Mon, 15 Nov 2004, Zack Weinberg wrote:
> >
> >> The thing I think we need to continue allowing, as long as the
> >> arithmetic-on-void* extension remains, is &ptr[N].
> >
> > Given the mandatory warning "dereferencing 'void *' pointer" for this I'd 
> 
> &(E1[E2]) is completely equivalent to ((E1)+(E2)), thus no such warning
> should be given.

No, it's equivalent to &*((E1)+(E2)).  The warning for dereferencing void 
* pointers is given on the dereference, whether or not the address is 
subsequently taken.  First the constraints for [] apply (and it's such a 
constraint for which a new specific diagnostic was proposed), then those 
for addition (which don't add anything beyond those for []) (it's at this 
point that -Wpointer-arith has traditionally warned: the constraints were 
checked as on the addition rather than those on the original []) and those 
for dereference (which allow dereference of void *, though we warn - and I 
suspect we also need to allow &* at least on pointers to incomplete 
structure and union types, as I can find nothing to restrict it or render 
it undefined), then those on &.  I think the warnings for intermediate 
steps make sense given that the constraints on intermediate steps are 
applied.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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