Get this pointer stuff over with, people

Chip Salzenberg chip at ateng.ateng.com
Tue May 23 04:40:50 AEST 1989


According to bph at buengc.BU.EDU (Blair P. Houghton):
>I'd also like to be able to add pointers as though they were data.

Of course, there's the '286...

    [thrown tomatoes obscure the speaker]

Ahem.  As I was saying, on the '286 -- and also on the '386, though it seems
that no one cares -- pointer values include both a segment portion and an
offset portion.  Arithmetic with pointer offsets is meaningful, but
arithmetic with pointer segments is not.  (One exception to that rule is
the provision for "huge" arrays which span segments, but this provision is
not standard C.)

Further, when the '286 is in protected mode -- as it always is when running
a Unix program -- the simple *assignment* of an invalid segment into a
segment register causes a protection trap and a SIGSEGV.

So there's really no way to perform integer-like arithmetic on a '286 pointer.
-- 
Chip Salzenberg             <chip at ateng.com> or <uunet!ateng!chip>
A T Engineering             Me?  Speak for my company?  Surely you jest!
	  "It's no good.  They're tapping the lines."



More information about the Comp.lang.c mailing list