Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcvax!unido!tub!cabo From: cabo@tub.UUCP Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++ - (nf) Message-ID: <48400001@tub.UUCP> Date: Mon, 14-Sep-87 16:06:00 EDT Article-I.D.: tub.48400001 Posted: Mon Sep 14 16:06:00 1987 Date-Received: Fri, 18-Sep-87 04:19:08 EDT References: <1459@cullvax.UUCP> Lines: 29 Nf-ID: #R:cullvax:-145900:tub:48400001:000:1164 Nf-From: tub!cabo Sep 14 21:06:00 1987 Several people have argued that arithmetic on null pointers should be disallowed in the C standard on the grounds that hardware may trap attempts to alter the special cookie that implements a null pointer. While I agree that char *p = 0; p++; should not be allowed by the standard, I see some benign applications for constant expressions involving null pointers, e.g. (char *)&((struct foo *)0)->bar - (char *)&((struct foo *)0)->baz for computing the relative offset of two structure members in character sized units. I'm not saying that the above is a constant expression according to the wording of the draft (I don't have it, unfortunately), but I would like it to be one. The alternative, declaring a dummy object (or worse, a dummy pointer that would have to be initialized via malloc()) just for being able to reference its members, doesn't appeal to me at all (is this PL/1?). Carsten -- Carsten Bormann, Communications and Operating Systems Research Group Technical University of Berlin (West, of course...) Path: ...!pyramid!tub!cabo from the world, ...!unido!tub!cabo from Europe only.