Re: Cray pointers
From: Arnaud Desitter (arnaud.desitterNOSPAM_at_NOSPAMouce.ox.ac.uk)
Date: Fri, 3 Dec 2004 12:30:14 -0000
"glen herrmannsfeldt" <email@example.com> wrote in message
> Richard E Maine wrote:
>> The "like references to variables" is an understatement. That's
>> basically exactly what they are - I don't think that the "like" part
>> is needed.
>> I'm not as fluent in C standard-speak, but I think that's also the
>> case in the C standard. Its just that the enforcement in C is so
>> weak, and the structure of a pointer tends to be so simple, that you
>> can pretty easily do "illegal" things like put an integer value into a
>> pointer without getting "caught". My possibly mistaken understanding
>> is that it is technically just as illegal in C as it is in Fortran.
> There are a fair number of things that are techinically illegal
> because someone could design a system where they wouldn't work,
> but for the most part will work. One is that C still allows
> sign magnitude and ones complement representation for integer
> variables. It seems that UNISYS does still make ones complement
> machines, and maybe they have a C compiler, but otherwise you
> are unlikely to run into one. C does allow bounds checking, though
> it is implemented much more rarely than for Fortran.
> In large model protected mode x86 code a pointer contains a segment
> selector and offset into the segment. A segment selector is an index
> into the segment descriptor table. It is illegal to load a segment
> register with a selector to a segment that doesn't exist. A
> hardware interrupt will stop you from doing it. I believe, though,
> that most C compilers won't load the segment register until just before
> actually using it. If you just store a value into a pointer, or
> copy pointers, it won't load them into a segment register.
> People have built hardware with tag bits that describe the data
> stored in each memory location (integer, real, character, pointer),
> where the hardware prevents many operations including storing
> integers into pointers.
> -- glen
Interesting. See Risks Digest 23.24 for more information about these
"tag bits". This reference cites:
"The Architecture of the Burroughs B5000 --20 Years Later
and Still Ahead of the Times?", Alastair J. W. Mayer,
ACM Computer Architecture News paper, 1982