🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #665

Re: Out-of-bounds pointers

#665
From: Walter Murray
Date: Wed, 04 Oct 1989 20:18
28 lines
1425 bytes
Ed Gould:

> Is the following code conformant?  It's clear that it's not legal to
> dereference the pointer in its "illegal" state, but is the p++ line
> guaranteed to return it to a valid value?

Henry Spencer:

> The effect of the `p--' line is undefined, so all bets are off.

Doug Gwyn:

> It's not even "legal" to compute an invalid address, whether or not
> it is dereferenced.

I agree with Henry and Doug (generally a safe bet!), but I do think
the wording of 3.3.6 might be misleading:  "Unless both the pointer
operand and the result point to elements of the same array object,
or the pointer operand points one past the last element of an array
object and the result points to an element of the same array object,
the behavior is undefined if the result is used as an operand of
the unary * operator."  Doesn't this imply rather strongly that it
IS legal to compute an invalid address, as long as it isn't
dereferenced?

Walter Murray
walter@hpda.HP.COM
---
Technical Details
Message-ID: <12570028@hpclwjm.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!usc!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
References: <1009@mtxinu.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!usc!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter
From: walter@hpclwjm.HP.COM (Walter Murray)
Newsgroups: comp.std.c
Subject: Re: Out-of-bounds pointers
Message-ID: <12570028@hpclwjm.HP.COM>
Date: 4 Oct 89 20:18:59 GMT
References: <1009@mtxinu.UUCP>
Organization: Hewlett-Packard Calif. Language Lab
Lines: 28