Re: decrement past beginning is valid?

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 11/05/04


Date: Fri, 05 Nov 2004 03:32:10 GMT


"Watson Davis" <watson@watsonmusic.com> wrote in message
news:Xns9597AC4FD1805thepencilneckyahooco@206.66.12.201...
> Francis Glassborow <francis@robinton.demon.co.uk> wrote in
> news:c7mowqa96riBFwfy@robinton.demon.co.uk:
>
> > In article <Xns959756278EEC1thepencilneckyahooco@206.66.12.208>,
> > Watson Davis <watson@watsonmusic.com> writes
> >>Pedro Graca <hexkid+usenet@gmail.com> wrote in
> >>news:slrncokhqt.9tq.hexkid+usenet@ID-203069.user.uni-berlin.de:
> >>
> >>> I know that incrementing a pointer one past the end of the array is
> >>> valid (as long as I don't dereference it).
> >>>
> >>> Is it valid to decrement before beginning of array?
> >>
> >>Sure. It's just a pointer and you can pretty much increment and
> >>decrement that thing all over the place without a problem. Well... if
> >>you ASSIGN something to the wrong place you can create some pretty
> >>magnificent problems...
> >
> > No, creating an address that is not owned by your process can and does
> > cause your program to abort on some platforms. The dispensation for
> > one-past-the-end is exactly a requirement on compilers for such
> > platforms to ensure that that address is owned by the process and so
> > does not cause the program to abort.
>
> You are misinterpreting my point.

I think he's *corrected* your point, which was incorrect.
One cannot indiscriminately increment or decrement a pointer
and expect nothing to go wrong. One must follow the rules.

-Mike