[Bug c/58217] New: warning when assigning a function pointer field in a structure having the may_alias attribute

2013-08-22 Thread z...@droids-corp.org
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.

[Bug c/58217] warning when assigning a function pointer field in a structure having the may_alias attribute

2013-08-22 Thread z...@droids-corp.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58217

--- Comment #1 from Olivier MATZ  ---
Created attachment 30685
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30685&action=edit
code that triggers the issue


[Bug c/58217] warning when assigning a function pointer field in a structure having the may_alias attribute

2013-08-22 Thread z...@droids-corp.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58217

--- Comment #2 from Olivier MATZ  ---
Created attachment 30686
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30686&action=edit
gcc -dumpspecs


[Bug c/58217] warning when assigning a function pointer field in a structure having the may_alias attribute

2013-08-22 Thread z...@droids-corp.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58217

--- Comment #3 from Olivier MATZ  ---
Created attachment 30687
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30687&action=edit
intermediate file foo.i