This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PR 6212
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Robert Dewar <dewar at gnat dot com>, "kenner at vlsi1 dot ultra dot nyu dot edu" <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 08 May 2002 07:40:40 -0700
- Subject: Re: PR 6212
- References: <20020508143400.114B2F2CB3@nile.gnat.com>
--On Wednesday, May 08, 2002 10:34:00 AM -0400 Robert Dewar
<dewar@gnat.com> wrote:
>> The type of a pointer is -- in your average type system -- purely
>> dependent on the type pointed to by the pointer. To say it points to
>> one kind of type, but another kind of object, is to have substantially
>> enrichened your type system in a way that is not clearly beneficial.
>
> I think you mean something like "representation of a pointer and allowable
> operations". Obviously the statement you gave is not true in any language
> with name equivalence of types. For example in Ada
>
> type A is access Integer;
> type B is access Integer;
>
> describe two quite different types (and indeed in Ada you cannot even
> assign one to the other, since these might be separate storage pools).
> Even if you force interconvertability
>
> type A is access all Integer;
> type B is access all Integer;
>
> they are still quite different types.
Right. Ada gives you finer control over some of these situations; in
C/C++ "typedefs" do not create new types; they create new names for old
types.
The point is that a minimal constraint on many type systems is that two
things with the same type support the same operations. (Note that this
doesn't talk about representation at all; if your language doesn't have
assignment-by-smushing-bits, representation may not matter.) If you want
to draw finer bondaries than that, you can of course do that. In C/C++,
representation matters greatly, so that becomes a finer distinction. We
also don't treat "int" and "long" as the same type, even if they have the
exact same representation. These GCC attributes essentially create new
types like "strangely-aligned, weirdly sized int" and that thing is only
a little bit more like an int than a short is like an int.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com