Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!n8emr!uncle!basho!john From: john@basho.uucp (John Lacey) Newsgroups: comp.lang.c Subject: Operations on pointers to void. Message-ID: <1990Aug9.231614.5196@basho.uucp> Date: 9 Aug 90 23:16:14 GMT Organization: Are you kidding? Lines: 34 What operations are legal on pointers to void? K&R2 is it's usual self on the matter---no one can tell if what they say is possible, required, complete, a couple of examples, or what. Harbison and Steele are their much more explicit selves, but still, all they say is that void *'s can be assigned to or from without casts, and that dereferencing and subscripting are illegal. But, what about pointer arithmetic? And it that is legal, what size object does a void * point to? If there was justice in the world, I suppose that it should be legal, and that a void * points to an object of size 0, but gcc thinks the size is 1 (and gives no complaints about the following code compiled with -ansi -pedantic -Wall: #include int main() { char foo [] = "This is a test string."; void * a = foo; void * b = &foo[1]; printf ( "%s\n", (++a == b) ? "Object size is 1" : "Object size is NOT 1" ); return ( 0 ); } and further, gives the aforementioned result of "Object size is 1"). Ah what gives? -- John Lacey, E-mail: ...!osu-cis!n8emr!uncle!basho!john (coming soon: john@basho.uucp) V-mail: (614) 436--3773, or 487--8570 "What was the name of the dog on Rin-tin-tin?" --Mickey Rivers, ex-Yankee CF