Path: utzoo!attcan!uunet!lll-winken!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: malloc impossible? Message-ID: <9351@smoke.BRL.MIL> Date: 12 Jan 89 16:21:24 GMT References: <19@xenlink.UUCP> <225800106@uxe.cso.uiuc.edu> <310@twwells.uucp> <9342@smoke.BRL.MIL> <15427@mimsy.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22 In article <15427@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >But I claim that, if the requirement for malloc() were dropped, one >could implement C-minus-malloc on a machine that (say) required all >floating point numbers to live in the floating-point address space, >by having two stacks (one in the integer space and one in the fp space) >and two data segments (likewise). Assuming that integers could not also live in floating-point space, C would not be implementable on such a hypothetical architecture. Consider union { double d; int i; } u; u.d = 123.0; printf("%d\n", u.i); This is required to work, although the specific value printed of course depends on details of numeric representation on the specific system. All data object types in C must be able to live in the same kind of space. Whatever kind of space that is, is what one would parcel out via malloc(). Therefore malloc() is implementable if C is (at the very least, along the lines I indicated in my previous example implementation).