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.