Messages in this thread | | | Date | Thu, 15 Apr 2004 20:58:04 -0400 | From | Jeff Garzik <> | Subject | Re: Linux 2.4.26-rc2 |
| |
Eyal Lebedinsky wrote: > Marcelo Tosatti wrote: > >> The void pointer case in here its being done math on without any >> problem. What is the >> problem with void pointer math > > > There is a problem regarding the C standard. The semantics of 'void *' > are well defined > and only allow for limited use. Basically, you can cast any pointer to > and from 'void *', > but nothing else. > > Pointer math says that 'p+n' means "add to 'p' the value 'n*s' where 's' > is the size > on the element that 'p' points to". A 'void *' does not have a defined > element size > until it is cast. So, ANSI specifically does not allow any arithmetics > on 'void *'. > > Some compilers are forgiving and will invent an element size of '1' and > allow the > math. We should not rely on such improper usage.
Void pointer arithmatic is an explicit gcc extension, and used extensively throughout the kernel.
Jeff
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |