This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/12846] New: No warning when function pointer cast drops __attribute__ ((regparm))


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]