|Pointers in C email@example.com (Phil Pfeiffer) (1988-07-05)|
|Re: Pointers in C firstname.lastname@example.org (1988-07-06)|
|Re: Pointers in C email@example.com (1988-07-06)|
|Re: Pointers in C firstname.lastname@example.org (1988-07-13)|
|Posted-Date:||Tue, 5 Jul 88 15:03:21 CDT|
|Date:||Tue, 5 Jul 88 15:03:21 CDT|
|From:||Phil Pfeiffer <email@example.com>|
Before other comp.compiler readers are quick to point out that my posting about
C's semantics was not totally accurate:
When I posted that C's semantic model allowed unconstrained use of pointers,
I said this based on my experience with the Unix C compiler, and did not
double-check K&R before posting. My mistake. I received two communiques
today from Bob Larson (firstname.lastname@example.org) that I'd like
to pass along (with his permission) before other comp.compiler readers
correct me, as well.
> But C does constrain pointer arithmatic to the bounds of the array.
> (ANSI will allow the address folowing the array to be calculated but
> not referenced.) Most compilers don't enforce this, but it is there
> in K&R ....
>K&R 1, page 98:
>"But all bets are off if you do arithmetic or comparisons with pointers
>pointing to different arrays. If you're lucky, you'll get obvious
>nonsense on all machines. If you're unlucky, your code will work on one
>machine but collapse mysteriously on another."
>This doesn't seem to be restated in the refernce manual section.
>My copy of K&R 2 is elsewhere, but I'm pretty sure the restriction still
>holds. (My info on ANSI C is mostly from comp.lang.c and comp.std.c,
>so is less than perfectly reliable.)
Also, on page 90 of K&R (version 1):
"You should also note the implications in the declaration that a pointer is
constrained to point to a particular kind of object."
I guess this is why formal language specification and compiler validation
[From Phil Pfeiffer <email@example.com>]
Return to the
Search the comp.compilers archives again.