Bug 33859 - Bogus "discards qualifiers" warning
Summary: Bogus "discards qualifiers" warning
Status: RESOLVED DUPLICATE of bug 29478
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-22 13:44 UTC by M Welinder
Modified: 2007-10-22 15:36 UTC (History)
10 users (show)

See Also:
Host: i686-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M Welinder 2007-10-22 13:44:37 UTC
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.
Comment 1 Richard Biener 2007-10-22 15:36:55 UTC

*** This bug has been marked as a duplicate of 29478 ***