p[1] vs. *(p+1)

Wayne Throop throopw at sheol.UUCP
Mon Sep 3 12:04:52 AEST 1990


> From: steve at groucho.ucar.edu (Steve Emmerson) 
>> [...] it is misleading to say that "adding one to p 'really' adds
>> sizeof(*p) to p".  [...] it "really" adds 1, and the result points at an
>> element [...] which is offset exactly 1 array element [...]
> Isn't the point moot if a conforming program can't tell the difference?

In terms of correctness, I agree (once one fills in the implied
information that one is assuming integer arithmetic on byte offset
pointers). 

But my point wasn't directed at correctness, but at communication.  So
I'd say the point is moot only if the difference in phrasing doesn't
mislead programmers into producing nonconforming programs.  And I think
it pretty clear that this particular issue misleads more people than
many another, and that extreme care in communication is warranted. 

Then again, maybe I'm just too picky... but I still don't think so.
--
Wayne Throop <backbone>!mcnc!rti!sheol!throopw or sheol!throopw at rti.rti.org



More information about the Comp.lang.c mailing list