Article View: comp.bugs.4bsd
Article #247Re: Bug in users command
From: Larry Jones
Date: Thu, 24 Jan 1991 20:40
Date: Thu, 24 Jan 1991 20:40
20 lines
1578 bytes
1578 bytes
In article <1991Jan24.060113.22461@tkou02.enet.dec.com>, diamond@jit345.swstokyo.dec.com (Norman Diamond) writes: > [ Given "char (*a)[N];", are "(char *)a", "&(*a)[0]", and "*a" equivalent? ] > > No. The last two yield pointers to the same char object, the first char in *a. > > The first one coerces a pointer-to-array to a pointer-to-char value. > The standard guarantees that you can take a pointer-to-something, cast it to > a pointer-to-char, cast it back to a pointer-to-something, and the result is > equivalent to the original pointer. It does not guarantee that the value > with type pointer-to-char can actually be used for anything. To rephrase, "Is a pointer to an array, when cast to the array element type, equivalent to a pointer to the first element of the array?" I believe that the standard imposes sufficient constraints on the implementation that the answer to that question must be "yes". ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 Domain: scjones@thor.UUCP Path: uunet!sdrc!thor!scjones Nobody knows how to pamper like a Mom. -- Calvin
Technical Details
Message-ID:
<136@thor.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sdrc!thor!scjonesReferences:
<6182:Jan2222:06:3991@kramden.acf.nyu.edu> <18981@rpp386.cactus.org> <1991Jan24.060113.22461@tkou02.enet.dec.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sdrc!thor!scjones From: scjones@thor.UUCP (Larry Jones) Newsgroups: comp.bugs.4bsd,comp.std.c Subject: Re: Bug in users command Message-ID: <136@thor.UUCP> Date: 24 Jan 91 20:40:57 GMT References: <6182:Jan2222:06:3991@kramden.acf.nyu.edu> <18981@rpp386.cactus.org> <1991Jan24.060113.22461@tkou02.enet.dec.com> Followup-To: comp.std.c Organization: SDRC, Cincinnati Lines: 20