Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!vsi!friedl From: friedl@vsi.COM (Stephen J. Friedl) Newsgroups: comp.lang.c Subject: Re: arithmetic on void pointers Summary: Chapter and verse... Message-ID: <1067@vsi.COM> Date: 7 Mar 89 03:45:32 GMT References: <1527@ncar.ucar.edu> Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 52 In article <1527@ncar.ucar.edu>, russ@groucho.ucar.edu (Russ Rew) writes: > What does the latest dpANS document say? Is it legal > to increment a variable of type void* ? No. When incrementing a pointer, one multiplies the increment by the size of the pointed-to object. Since a `void' has no size, you can't get to the next one. The dpANS does not directly say "You can't ++ a void*", so to prove it you need to string a couple of parts together. From the May88 dpANS: (renditions: ITALICS, /Courier/) 3.1.2.5 - Types "The /void/ type comprises an empty set of values; it is an incomplete type that cannot be completed" ### /void/ is an incomplete type 3.3.3.4 - The /sizeof/ operator "The /sizeof/ operator shall not be applied to an expression that has function type or an incomplete type [...]" ### you can't take the size of /void/ 3.3.2.4 - Postfix increment and decrement operators and 3.3.3.1 - Prefix increment and decrement operators "The operand of the prefix increment or decrement operator shall have qualified or unqualified scalar type and shall be a modifiable lvalue." ### you can't ++ or -- a /void/ I would guess that those implementations that permit ++ on void pointers do so by treating them as char pointers instead. Steve, the staggering dpANS (with apologies to Karl) -- Stephen J. Friedl / V-Systems, Inc. / Santa Ana, CA / +1 714 545 6442 3B2-kind-of-guy / friedl@vsi.com / {attmail, uunet, etc}!vsi!friedl "Cold beer, hot women, and fast compilers" - me