Path: utzoo!utgpu!attcan!uunet!peregrine!elroy!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Is range(ptrdiff_t) > range(size_t)? Message-ID: <8275@brl-smoke.ARPA> Date: 30 Jul 88 19:43:20 GMT References: <3740@psuvax1.cs.psu.edu> <485@draken.nada.kth.se> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17 In article <485@draken.nada.kth.se> pk-tle@draken.UUCP (Tommy Levitte) writes: >>Is the following relationship always true? >> sizeof(char a[]) == &a[sizeof(a)] - &a[0] >No! If you use any C on a PC system, this will never be true, due to the >segment:offset adress format. Yes! At least, modulo correcting the syntax of the example, C requires the relationship to be true. On a segmented architecture, if the array is allocated within a single segment, it is easy to ensure this. Otherwise, the compiler will have to use more involved pointer operation support, but it's still required that the difference of two pointers into an array yield the number of array elements between them (give or take 1). If your compiler doesn't do this, it is broken.