lcc.dab@UCLA-LOCUS.ARPA@sri-unix.UUCP (03/26/84)
From: David Butterfield <lcc.dab@UCLA-LOCUS.ARPA> First, I have seen it stated on this list that "char * is guaranteed by the language to be the widest pointer". I cannot seem to find this in the K&R, however. Reference to chapter and verse would be appreciated. Second, K&R section 14.4, paragraph 4, sentence 3 says: "It is guaranteed that a pointer to an object of a given size may be converted to a pointer to an object of a smaller size and back again without change." My question then is: For purposes of the above sentence, what is the size of a function relative to the data types. I know how to find the size of a data object using the sizeof operator. I don't know how to find the size of a function. (Some might say that the "size" of a function is the number of "bytes" between the closest possible starting points of functions. On the PDP-11, this would be 2, since functions must start on even addresses.) The question becomes much worse, however, when functions and data live in different address spaces with different sizes. For example, consider a Large Text, Small Data 8086 C compiler. Here, a char * would reasonably be 16 bits and a function * would have to be 32 bits. Here, functions would seem to be "smaller" than chars. Worse yet would be a machine where different data types could live in various different address spaces with different lengths, but lets not get carried away. (Some might say that for purposes of the above quote, the "size" of an object is the fraction of its address space that it consumes. In the case of data, the fraction is computed using the length of the object. In the case of functions, the fraction is computed using the closest possible starting points. This is yucky, but seems to reflect what size of pointer is required.)