Message from discussion
About the array subsripting operator
Received: by 10.180.105.38 with SMTP id gj6mr5140817wib.0.1346980556080;
Thu, 06 Sep 2012 18:15:56 -0700 (PDT)
Path: ed8ni5441034wib.0!nntp.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!216.196.110.144.MISMATCH!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: Eric Sosman <esos...@ieee-dot-org.invalid>
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: About the array subsripting operator
Followup-To: comp.std.c
Date: Thu, 30 Aug 2012 12:58:26 -0400
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <k1o63l$kfi$1@dont-email.me>
References: <9104981e-cf45-425b-ad84-c068636086eb@googlegroups.com>
Mime-Version: 1.0
Injection-Date: Thu, 30 Aug 2012 16:58:29 +0000 (UTC)
Injection-Info: mx04.eternal-september.org; posting-host="ffb8f7085759b339c1002252b48331a4";
logging-data="20978"; mail-complaints-to="ab...@eternal-september.org"; posting-account="U2FsdGVkX18OSmM3qsugrNV0rYtDRArq"
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0
In-Reply-To: <9104981e-cf45-425b-ad84-c068636086eb@googlegroups.com>
Cancel-Lock: sha1:NEtRhN1lBx90Ak63U0a0SJzA2Y4=
Bytes: 2378
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
On 8/30/2012 12:32 PM, Kirilenko wrote:
> Hey c.l.c. !
>
> I was reading the C11 standard (�6.5.2.1) :
>
>> The definition of the subscript operator [] is that E1[E2] is identical to
>> (*((E1)+(E2))).
>
> I would like to know why are brackets around E1 necessary (they were missing
> in the C89 standard), ie in which case can (*(E1+(E2))) be different from
> (*((E1)+(E2))) ?
The parentheses would only make a difference if E1 were an
expression involving operators of lower precedence than `+'.
But any such operator would also have lower prececence than `[]',
so E1 would already need to be parenthesized:
(which ? array1 : array2) [i]
not
which ? array1 : array2 [i]
Perhaps the extra parentheses were added for clarity's sake, in
the fear that someone might think E1 in the first line above
was the "bare" `which ? array1 : array2', which would make hash
of the stated equivalence.
(Questions about "Why is the Standard written in thus-and-such
a way?" will probably do better in comp.std.c than in comp.lang.c.
CC'ed, and follow-ups set.)
--
Eric Sosman
esos...@ieee-dot-org.invalid