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


"Joseph S. Myers" <joseph@codesourcery.com> writes:

> 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)).

See 6.5.3.1p3 and footnote 83:

   Similarly, if the operand is the result of a [] operator, neither the &
   operator nor the unary * that is implied by the [] is evaluated and the
   result is as if the & operator were removed and the [] operator were
   changed to a + operator.

   83) Thus, &*E is equivalent to E (even if E is a null pointer), and
       &(E1[E2]) to ((E1)+(E2)).

So it all boils down to "arithmetic on void *", but _not_ "dereferencing
void *".

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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