Deutsch   English   Français   Italiano  
<v6c3s3$3tl33$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!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: Sat, 6 Jul 2024 19:53:56 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <v6c3s3$3tl33$2@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 06 Jul 2024 20:53:55 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c37fc5164b87e9d2d37a8965ff47e68e";
	logging-data="4117603"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18IwSZXi9f4B0TE1fgqY11A"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LQIEwwB09uAj2boZ5HCSb0ygXFE=
In-Reply-To: <v6c2d7$3tko2$2@dont-email.me>
Content-Language: en-GB
Bytes: 2918

On 06/07/2024 19:28, James Kuyper wrote:
> On 7/6/24 03:23, Lawrence D'Oliveiro wrote:
>> On Fri, 05 Jul 2024 11:46:38 -0700, Keith Thompson wrote:
>>
>>> No, arrays are not pointers.
>>
>> Except array indexing is designed to be indistinguishable from pointer
>> arithmetic.
> 
> Actually, C doesn't have array indexing; it only has pointer indexing.
> The subscript operator requires that one of it's operands shall have the
> type "pointer to a complete object type", and that the other shall have
> integer type. It cannot be applied to arrays; but conveniently, the
> standard mandates that:
> 
> "Except when it is the operand of the sizeof operator, or typeof
> operators, or the unary & operator, or is a string literal used to
> initialize an array, 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

'Subscripting' I think we can agree is the same thing as 'indexing': 
what those funny square brackets do.




> It is that conversion which creates the illusion of array indexing, but
> since it's been converted to a pointer, it is actually pointer indexing.

Isn't that how all languages work 'under the hood'? The net affect from 
the user's point of view is that you have an array object, and use 
'indexing' to access its individual elements.