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: Sat, 11 Jan 2020 10:24:59 -0800 Organization: A noiseless patient Spider Lines: 42 Message-ID: <86lfqd26mc.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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="a658bb27d1b88b897660621da5fe7a9e"; logging-data="30932"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ic6wxjkb5SZsT0LxEpJEGizDtkJy5eVQ=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:MFftlBDv1eVm2WfOc06zxGsnm8k= sha1:/hzyZxM3wK0MNxVGANuYDh6Pn3Q= Xref: csiph.com comp.lang.c:148941 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.