Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Why no arithmetic on void * Message-ID: <14948@smoke.brl.mil> Date: 23 Jan 91 23:27:53 GMT References: <1238@dkunix9.dk.oracle.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <1238@dkunix9.dk.oracle.com> bengsig@dk.oracle.com (Bjorn Engsig) writes: >Could someone please explain if arithmetic on void * (with the same semantics >as on char *) was discussed when ANSI C was made, and why it was not included. The main purpose of void and void* was to provide additional compile-time safety checking. This would be largely defeated if pointer arithmetic had been allowed on void*. Note that such arithmetic would have had to have been specially defined for that one type, since it does not fit the pointer-arithmetic model given for additive operators. (If it HAD been made consistent, we would have had to declare that sizeof(void)==0 and then void* arithmetic would not have had the same behavior as char* arithmetic anyway. So it would have had to violate the model, which is obviously extremely undesirable.) Note also that there is absolutely no need for such a wart, since you can perform the desired pointer arithmetic after casting the void* to char*.