Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: pointer alignment when int != char * Message-ID: <6110@brl-smoke.ARPA> Date: Sun, 12-Jul-87 16:58:14 EDT Article-I.D.: brl-smok.6110 Posted: Sun Jul 12 16:58:14 1987 Date-Received: Mon, 13-Jul-87 04:55:58 EDT References: <493@its63b.ed.ac.uk> <6061@brl-smoke.ARPA> <3812@spool.WISC.EDU> <13218@topaz.rutgers.edu> <6655@steinmetz.steinmetz.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 Xref: mnetor comp.lang.c:3013 comp.unix.wizards:3221 In article <6655@steinmetz.steinmetz.UUCP> davidsen@kbsvax.steinmetz.UUCP (William E. Davidsen Jr) writes: >Why not have int be 32 bits? That fits the requirement that >length char<=short<=int<=long. Not a comment, just a question... There are two main considerations for the correct size to be used for (int) when implementing C on a new system: 1. (int) objects should be accessible quickly. On a word-addressed architecture, this argues for making them full words. 2. (int)s must be usable for indexing arrays. Depending on the address space, one may have to either impose an artificial limit on array sizes or else make (int)s longer than they might have been. For example, on a hypothetical PDP-11AX (which doesn't exist because it turned into a VAX), one could have had 16 bits continue to be the natural integer data size but 24 or 32 bits could have been the preferred pointer size due to an extended addressing scheme using base registers a la Gould. The C implementor would almost certainly have wanted to make the larger address space available on such a machine, which would force some sort of accommodation to be made for indexing char arrays -- probably by making (int)s as wide as char pointers. I understand from hearsay that the IBM PC world (actually the Intel 8086 world) ran against this very problem, and instead of making a single sane choice they ended up proliferating a variety of incompatible sets of choices (hilariously called "models"). One hopes that a lesson was learned, but I doubt it.