This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: does gcc support multiple sizes, or not?


> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf
Of
> Mark Mitchell
> Sent: Monday, August 14, 2006 12:50 PM
> To: DJ Delorie
> Cc: kenner@vlsi1.ultra.nyu.edu; gcc@gcc.gnu.org
> Subject: Re: does gcc support multiple sizes, or not?
> 
> DJ Delorie wrote:
> >> And back to my original answer: it's up to each language to decide
> >> that.
> >
> > Hence my original question: is it legal or not?  What did the C++
> > developers decide?
> 
> The C++ standard implies that for all pointer-to-object types have the
> same size and that all pointer-to-function types have the same size.
> (Technically, it doesn't say that that; it says that you can convert
T*
> -> U* -> T* and get the original value.)  However, nothing in the
> standard says that pointer-to-object types must have the same size as
> pointer-to-function types.

The C standard says that all pointer to structure and unions must have
the same size and format as each other, since otherwise declaring
pointers to structure tags that aren't declared in this module would not
be compatible with the same declaration in another module where you do
declare the structure tag.  When the ANSI C-89 (and later ISO C-90)
standard came out, I was working on a C compiler for a machine with
different flavors of pointers, and so I was very aware of the ins and
outs.  Pointers to functions can be a different size than pointers to
data, which is one of the reasons in C-89 you can't assign a function
pointer to a void *.  Because of the rule for functions with no
prototypes (since deprecated in C-99), all function pointers must be the
same size as each other.
 
> In theory, I believe that G++ should permit the sizes to be different.
> However, as far as I know, none of the G++ developers considered that
> possibility, which probably means that we have made the assumption
that
> they are all the same size at some points.  I would consider places
> where that assumption is made to be bugs in the front end.

I think having pointers be the same size is ingrained in the whole
compiler, not just the front ends.  I did a port to a machine (Mitsubshi
D10V) that had different flavors of pointers, though thankfully they
were the same size (pointers to functions were pointers to 32-bit
instruction words, while pointers to data were bytes to 8-bit bytes).
When I did that compiler (GCC 2-3 time frame), there were many
limitations caused by this, including the prohibition against
trampolines.

--
Michael Meissner
AMD, MS 83-29
90 Central Street
Boxborough, MA 01719



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]