This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/12846] New: No warning when function pointer cast drops __attribute__ ((regparm))
- From: "anders at kaseorg dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Oct 2003 19:59:55 -0000
- Subject: [Bug c/12846] New: No warning when function pointer cast drops __attribute__ ((regparm))
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12846
Summary: No warning when function pointer cast drops
__attribute__ ((regparm))
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anders at kaseorg dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
The following code is invalid and won't work correctly (because the cast drops
the __attribute__ and changes the calling convention):
void test (int a) __attribute__ ((regparm (3)));
...
void (*ptest) (int) = test; /* wrong */
ptest (a);
However, GCC miscompiles it without a warning. If the same thing is done with
__attribute__ ((stdcall)) instead (which also changes the calling convention),
GCC gives "warning: initialization from incompatible pointer type". Shouldn't it
give this warning for __attribute__ ((regparm (3))) as well?