Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!mailrus!cornell!uw-beaver!uw-june!pardo From: pardo@june.cs.washington.edu (David Keppel) Newsgroups: comp.lang.c Subject: Re: array[-1] -- permitted? Message-ID: <5812@june.cs.washington.edu> Date: 23 Sep 88 01:00:13 GMT References: <1237@imagine.PAWL.RPI.EDU> <816@goofy.megatest.UUCP> Reply-To: pardo@uw-june.UUCP (David Keppel) Organization: U of Washington, Computer Science, Seattle Lines: 36 djones@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@cs.washington.edu {rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo