Rutger Hofman wrote:
Andrew Lunn wrote:
Hi Folks

Can anybody figure out what the compiler does not like:

/home/lunn/eCos/anoncvs-clean/packages/language/c/libc/string/current/tests/memchr.c: In function 'main': /home/lunn/eCos/anoncvs-clean/packages/language/c/libc/string/current/tests/memchr.c:103: warning: assignment discards qualifiers from pointer target type

OK, I try a bit harder. I reproduce this warning only with my native gcc-snapshot which is gcc (Ubuntu 20080404-0ubuntu1) 4.3.1 20080404 (prerelease) [gcc-4_3-branch revision 133917]. None of the other gcc's do this, not even 4.3.2-arm-eabi.

The result of memchr is assigned to a variable void *ret. If the type of ret is changed to 'const void *', the warning disappears. This is in contradiction with the prototype for memchr: void *memchr(const void *s, int c, size_t n). (Even though a return of const void * might actually be better).

Rutger

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply via email to