Deutsch English Français Italiano |
<v6lm05$1s105$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: =?UTF-8?Q?Re=3A_technology_discussion_=E2=86=92_does_the_world_need?= =?UTF-8?B?IGEgIm5ldyIgQyA/?= Date: Wed, 10 Jul 2024 10:58:30 +0100 Organization: A noiseless patient Spider Lines: 53 Message-ID: <v6lm05$1s105$1@dont-email.me> References: <v66eci$2qeee$1@dont-email.me> <v67gt1$2vq6a$2@dont-email.me> <v687h2$36i6p$1@dont-email.me> <871q48w98e.fsf@nosuchdomain.example.com> <v68dsm$37sg2$1@dont-email.me> <87wmlzvfqp.fsf@nosuchdomain.example.com> <v6ard1$3ngh6$4@dont-email.me> <v6c2d7$3tko2$2@dont-email.me> <v6c3s3$3tl33$2@dont-email.me> <v6la9f$1q63l$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 10 Jul 2024 11:58:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ded9e1848a26cfa2c70264cde0490f0f"; logging-data="1967109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+buTDx4bmxiEh+lReHnvSR" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:kK3F58xYzvJM7Z3bmRdPUb8LQx8= In-Reply-To: <v6la9f$1q63l$1@dont-email.me> Content-Language: en-GB Bytes: 3608 On 10/07/2024 07:38, James Kuyper wrote: > On Sat, 6 Jul 2024 19:53:56 +0100, bart wrote: > >> On 06/07/2024 19:28, James Kuyper wrote: >> >>> ... an expression that has type "array of type" is >>> converted to an expression with type "pointer to type" that points to >>> the initial element of the array object ..." (6.3.2.1p3). >> >> This is really, really pedantic. Even gcc doesn't get it right in that >> case, because if I try and compile this: >> >> int a, b> a[b]; >> >> it says: >> >> error: subscripted value is neither array nor pointer nor vector > > There is no expression that has the type "array of type" in the above > code. How is that relevant to what I wrote? > > For the subscript operator: > "One of the expressions shall have type "pointer to complete object > type", the other expression shall have integer type," (6.5.2.1p1) > > Neither a nor b has the type "pointer to complete object type". Both a > and b have the type 'int'. How did you expect that code to be meaningful? > > Note that a[&b] would be valid, since &b is treated for this purpose as > a pointer to the first element of a 1-element array. > > Note that the standard doesn't mandate which expression have the pointer > type; that's because a[&b] is defined as *(a + &b), and you can add a > pointer to an integer in either order, so you can subscript an array as > array[5] or 5[array]. > >> 'Subscripting' I think we can agree is the same thing as 'indexing': >> what those funny square brackets do. > > I can agree that subscripting is indeed what those square brackets do. > The C standard never mentions indexing, but I do agree that there is a > correspondence. However, if you derive any conclusions from that > correspondence that contradict what the C standard says about > subscripting, those conclusions are invalid. My post was about what gcc says. Your point I believe was about the fact that indexing / subscripting can only be meaningful with a pointer type, according to C, and not an 'array' or 'vector'. But gcc does mention subscripting in connection with arrays and vectors. So /my/ point is that sometimes it is helpful not to be so strict if it helps understanding.