I was surprised that gcc did not find an error in the following example. My understanding is that assignment to a void pointer is ok, but arithmetic is _not_ ok. I have tried this code on my arm cross compiler gcc v. 4.1.1 and my ubuntu system compiler 4.1.3. Gcc treats the void pointer type as char
gcc --version gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2) Example pointer arithmetic on a void pointer that should have caused an error #include <stdlib.h> int main (int argc, char **argv) { void *x; x = malloc(1025 * sizeof(*x)); x++; // i expected an error on this line! return 1; } -- Summary: pointer arithmetic on void pointers does not generate an error Product: gcc Version: 4.1.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jmparker at marvell dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34326