http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58217
Bug ID: 58217
Summary: warning when assigning a function pointer field in a
structure having the may_alias attribute
Product: gcc
Version: 4.7.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: z...@droids-corp.org
Host: x86_64
Target: x86_64
Hello,
When compiling the attached code, I get the following error:
$ gcc -Wall -Wextra foo.c
foo.c: In function ‘main’:
foo.c:16:16: warning: assignment from incompatible pointer type [enabled by
default]
If I remove the "__attribute__((may_alias))", it compiles. A workaround it
to cast the cb function pointer in (void *) before doing the affectation. In my
opinion, this warning is not expected here. Sorry if I missed something.
I also tried:
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv foo.c
foo.c: In function ‘main’:
foo.c:16:16: warning: assignment from incompatible pointer type [enabled by
default]
$ gcc --version
gcc (Debian 4.7.3-4) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I can reproduce the problem on several gcc versions 4.4, 4.5, 4.6 at least.