From -4022424697561436456
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9684813612e15361
X-Google-Attributes: gidf78e5,public
From: clamage@Eng.Sun.COM (Steve Clamage)
Subject: Re: pointers: sizeof(pointer)
Date: 1998/06/25
Message-ID: <6mu1lq$fon@engnews1.Eng.Sun.COM>#1/1
X-Deja-AN: 366134060
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <slrn6oqcgp.lfi.sbnaran@bardeen.ceg.uiuc.edu> <6mkkaq$dgu@engnews1.Eng.Sun.COM> <3591A612.15DA@aristeia.com>
X-Original-Date: 25 Jun 1998 17:33:46 GMT
Organization: Sun Microsystems Inc., Mountain View, CA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANZLcyOEDnX0m9pzZAQEadgF/VmUQBHDQhlyfD3pUbGYPFWosMND7w5I6 NPLO4607Org6VCx0sPXLHV4nKmCLLLav =0q+S
Newsgroups: comp.std.c++


Scott Meyers <smeyers@aristeia.com> writes:

>In the latest MSJ (July), Matt Pietrek explains why 64-bit Windows NT will
>use 64-bit pointers and 32-bit longs.  Believe it or not, it's not just to
>make life miserable for Unix developers :-)

I haven't seen the article, but we at Sun agonized for a long
time over the sizes of basic types in 64-bit Solaris (Sun's
version of Unix).

Pointers had to be 64 bits, since even 32-bit Solaris supports
64-bit file sizes, and files can be mapped into the memory space
of a program.  Beyond that, Sun makes desktop computers with more
than 4 Gb of main memory, and servers with much more than that.

Type int could (and should) remain at 32 bits. Sun C and C++
already had the common extension of type "long long" at
64 bits. Making it 128 bits was a possibility, but leaving
it at 64 bits would reduce program porting problems. It
also meant we didn't have to implement 128-bit arithmetic.

Type long was the problem child. On the one hand, gobs of
existing code (ours and customers') assumes that int and long
are the same size.  On the other hand, gobs of existing code
assumes that pointers and long are the same size. (On the
gripping hand, some code foolishly assumes that pointers and
int are the same size. Too bad.)

Add into the mix that 64-bit Solaris supports creating and
executing 32-bit programs directly, and we didn't want to force
programmers to customize application programs on the basis of
whether code would be compiled in 32-bit or 64-bit mode.

We came to the conclusion that it was better to break the
compatibility of int and long and allow a standard integer
type (instead of only a language extension) to be the same
size as pointers. Existing 32-bit programs will usually
continue to work if they assume int and long value ranges are
compatible. Programs that assume int and long use the same
amount of storage will break in 64-bit mode.

Evidently Microsoft evaluated their tradeoffs differently.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



