A warning is missing. When functions differ by number of args,
a warning gets produced. None is provided for an ABI difference.

foo 0 $ cat mismatch.c
#ifdef TWO
typedef int(*fn_t)(int a, int b)__attribute__(( regparm(0) ));
#else
typedef int(*fn_t)(int a, int b, int c)__attribute__(( regparm(0) ));
#endif
int foo(fn_t fn);
int bar(int a, int b, int c) __attribute__(( regparm(3) ));
int baz(void){
        return foo(bar);
}
foo 0 $ gcc -W -Wall -O2 -c mismatch.c 
foo 0 $ gcc -W -Wall -O2 -DTWO -c mismatch.c 
mismatch.c: In function ‘baz’:
mismatch.c:9: warning: passing argument 1 of ‘foo’ from incompatible pointer
type
foo 0 $


-- 
           Summary: ABI not considered when checking if function pointers
                    are compatible
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: acahalan at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29247

Reply via email to