Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Do "C" arrays start a 0 or 1?
Date: Tue, 21 Jan 2020 04:21:38 -0800
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <86wo9lhuel.fsf@linuxsc.com>
References: <87pnfxmz0i.fsf@nosuchdomain.example.com> <874kx7n5dr.fsf@nosuchdomain.example.com> <2e2172e1-a6e4-4488-89e9-f93036b839c0@googlegroups.com> <87v9pnktim.fsf@nosuchdomain.example.com> <86lfqd26mc.fsf@linuxsc.com> <87h811k4yo.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d01dc2e4789bccc98e4eaed72337c14b"; logging-data="32204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+T47HoqbJbajv/9Cvob6WMGjq43jhjlUY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:SwOXGIkE3a/OdwgiPJ2eratQ15o= sha1:ZeEtVTwIkEmj5dIoB7Fo5V9Qaeo=
Xref: csiph.com comp.lang.c:149304
Keith Thompson writes:
> Tim Rentsch writes:
>
>> Keith Thompson writes:
>>
>>> Bart writes:
>>> [...]
>>>
>>>> For this purpose, address and pointer may be used
>>>> interchangeably. Technically, in C a pointer is an address with type
>>>> information.
>>>
>>> Technically, in C an address has type information. The standard
>>> doesn't have a formal definition of "address", and some of its uses
>>> are a little ambiguous, but in most cases it refers to a value of
>>> pointer type.
>>>
>>> For example, the unary & operator "yields the address of its
>>> operand". That's a typed value of pointer type.
>>>
>>> Informally, an address is a value of pointer type (probably excluding
>>> null pointer, invalid pointers, and pointers just past the end of
>>> an object).
>>
>> I don't agree with this interpretation. If we look at all the
>> places the word "address" is used in the C standard, it doesn't
>> fit many of them (and I think it doesn't fit most of them but I
>> haven't checked that carefully).
>>
>> Furthermore I strongly suspect the term "address" is defined in
>> one of the C standard's normative references. If it is, then the
>> normative reference surely would not include any information
>> about a type in C.
>>
>> A better interpretation IMO is that "address" just means an address
>> as the term is usually used when talking about computer hardware,
>> and a pointer value includes an address (in some representation)
>> but isn't necessarily just an address. Note also that pointer
>> _values_ don't have any type information. A pointer-valued
>> _expression_ has some type information, but that information exists
>> only at compile time. Addresses are a run-time construct, not a
>> compile-time construct -- even though in some cases some address
>> values may be known at compile time, addresses are still a run-time
>> construct. This means they do not have type information, which
>> exists only at compile time.
>
> In a quick scan through N1570 (not including section 7), I don't see
> *any* uses of the term address that are inconsistent with my
> interpretation, except perhaps in uses of the phrase "address space".
> Some uses could be consistent with either your interpretation or mine.
What I did is bring up a copy of the Standard in Adobe Reader,
and use the search feature to find all occurrences of the word
"address", including as part of another word and with no case
differentiation. I went through the search results, looking
carefully at each usage and its surrounding context. What I saw
was consistent in every case with my reading but was in some
cases was not consistent with your reading. If you go through a
similar procedure and look carefully at every occurrence of
searching for the string "address" I suspect you will find some
that don't really fit with the idea that "address" is associated
with type information.