🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6145

a[], *p: if 0 <= p - a < sizeof(a), must p point to an element of a?

#6145
From: brnstnd
Date: Thu, 04 Jan 1990 18:39
8 lines
845 bytes
Basically, I want to have a guaranteed test of whether p points to an
element of a, with foo a[N] and foo *p. I know that *if* p points to an
element of a, *then* 0 <= p - a < sizeof(a); is the reverse true? (If
yes, please explain the logic.)

The standard should define pointer subtraction more carefully.

---Dan
Technical Details
Message-ID: <875@stealth.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!stealth.acf.nyu.edu!brnstnd

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!stealth.acf.nyu.edu!brnstnd
From: brnstnd@stealth.acf.nyu.edu
Newsgroups: comp.std.c
Subject: a[], *p: if 0 <= p - a < sizeof(a), must p point to an element of a?
Message-ID: <875@stealth.acf.nyu.edu>
Date: 4 Jan 90 18:39:53 GMT
Sender: brnstnd@stealth.acf.nyu.edu
Reply-To: brnstnd@stealth.acf.nyu.edu (Dan Bernstein)
Distribution: usa
Organization: IR
Lines: 8