array[-1] -- permitted?
David Keppel
pardo at june.cs.washington.edu
Fri Sep 23 11:00:13 AEST 1988
djones at megatest.UUCP (Dave Jones) writes:
>[ yacc example ]
The C standard does not tsy that computing a negative offset off of
a pointer is illegal, it says that computing one that is outside of
the array that the pointer points in to (the a single object is an
array of size 1) iis not standard C.
In the case of the YACC example, consider the following:
int a[10];
int *ip;
ip = &a[0];
&ip[-1]; /* iplementation-defined behavior */
&ip[0]; /* just fine */
&ip[9]; /* just fine */
&ip[10]; /* just fine */
ip[10]; /* iplementation-defined behavior */
ip = &a[5];
&ip[-6]; /* iplementation-defined behavior */
&ip[-5]; /* just fine */
&ip[4]; /* just fine */
&ip[5]; /* just fine */
ip[5]; /* iplementation-defined behavior */
And that's the way it is.
;-D on ( My goodness and my badness ) Pardo
--
pardo at cs.washington.edu
{rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo
More information about the Comp.lang.c
mailing list