Re: Cray pointers

From: Arnaud Desitter (arnaud.desitterNOSPAM_at_NOSPAMouce.ox.ac.uk)
Date: 12/03/04


Date: Fri, 3 Dec 2004 12:30:14 -0000


"glen herrmannsfeldt" <gah@ugcs.caltech.edu> wrote in message
news:conunt$bhp$1@gnus01.u.washington.edu...
>
>
> Richard E Maine wrote:
>
> (snip)
>
>> 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

As well, see http://slashdot.org/comments.pl?sid=20172&cid=2174329

Regards,



Relevant Pages

  • Re: how do you start learning assembly language
    ... > segment selector and an offset within the segment. ... then the linker has to do the relocation. ... change every "Item" (pointer) in each and every image? ... SizeOfOptionalHeader; SizeOfOptionalHeader ...
    (alt.lang.asm)
  • Re: Trap representations
    ... bytes directly (via a general integer register) and not needing to load ... segment register with the segment portion of an invalid pointer, ... Leave the pointer in memory, ...
    (comp.lang.c)
  • Re: Finding out if a struct is in an array of structs
    ... requiring pointer normalisation. ... that something somewhere needs to know what segment it's in. ... "near" pointers only contain an offset. ... The default pointer type depends on the "memory model" used. ...
    (comp.lang.c)
  • Re: Cray pointers
    ... In large model protected mode x86 code a pointer contains a segment ... it won't load them into a segment register. ... People have built hardware with tag bits that describe the data ...
    (comp.lang.fortran)
  • Re: Highly efficient string reversal code
    ... uninitialised pointer. ... NOTE Possible undefined behavior ranges from ignoring the ... very beginning of a segment. ... standard is specifically designed to allow such an implementation. ...
    (comp.lang.c)