[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Whats wrong with this program?



#include <stdio.h>
#include <string.h>

int main()
{
	char a[1] = { 'a' };
	memset(a,0,sizeof(a));	
	printf("%s",strdup("hello"));
	return(0);
}

generates lots of warnings.

[541] [dewey:bam] ~/cvswork/heimdal >gcc test.c -o test -O2 -Wpointer-arith -Wall
In file included from /usr/include/string.h:346,
                 from test.c:2:
/usr/include/bits/string2.h: In function `__strcpy_small':
/usr/include/bits/string2.h:419: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:427: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:432: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:437: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:439: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:444: warning: pointer of type `void *' used in arithmetic
test.c: In function `main':
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic
test.c:7: warning: pointer of type `void *' used in arithmetic

The reason I ask, is that this same situation occurs for most
files in Heimdal, and gets to be annoying.

IMHO, any void * pointer manipulation is very broken, and
I would have expected better from glibc :-(.
-- 
Brian May <bam@snoopy.apana.org.au>


Reply to: