This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81631] New: -Wcast-qual false positive for pointer to array
- From: "gcc17 at cwde dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 31 Jul 2017 11:03:59 +0000
- Subject: [Bug c/81631] New: -Wcast-qual false positive for pointer to array
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81631
Bug ID: 81631
Summary: -Wcast-qual false positive for pointer to array
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc17 at cwde dot de
Target Milestone: ---
Hi,
------
typedef int footype[6];
extern void const * bar;
void baz(void)
{
footype const * x;
x = (footype const *) bar;
}
------
with -Wcast-qual, this yields
------
$ gcc -Wcast-qual -c foo.c
foo.c:12:7: warning: cast discards 'const' qualifier from pointer target type
[-Wcast-qual]
x = (footype const *) bar;
^
------
If "footype" is any other type than an array, I don't get the warning. I tested
gcc 4.5.1, 6.3.0, 7.1.0, on cygwin and Debian, all show this behavior. clang
doesn't warn.