static void foo (char *s) { } void bar (const char *s) { foo ((char *)s); } gcc 4.2.0 produces this warning with -Wall -O2: www.c:2: warning: passing argument 1 of `foo' discards qualifiers from pointer target type. Due to the cast, the argument already has the right type, so gcc should not warn. The warning disappears without -O2. gcc 4.1.1 did not produce this warning.
*** This bug has been marked as a duplicate of 29478 ***