[Bug c/12846] New: No warning when function pointer cast drops __attribute__ ((regparm))
anders at kaseorg dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 30 20:19:00 GMT 2003
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?
More information about the Gcc-bugs
mailing list