Why does casting a function generate a run-time abort?
Andrew Pinski
pinskia@physics.uc.edu
Fri Jun 18 02:03:00 GMT 2004
> Compiling the following snippet
>
> typedef struct objc_Object * foo_id ;
> typedef struct blortstruct *blort ;
> extern foo_id objc_msgSend(foo_id, ...);
>
> int main(int argc, char * argv[])
> {
> blort foo = 0, bar = 0 ;
> foo_id obj0;
> obj0 = ((foo_id ((*)(foo_id, char *, blort, blort))) &objc_msgSend)
> (obj0, "foo message", foo, bar);
> return 0;
> }
>
> on the current TOT produces the following messages:
>
> R3692996.c: In function `main':
> R3692996.c:9: warning: function called through a non-compatible type
> R3692996.c:9: note: if this code is reached, the program will abort
Just some links to ponder on:
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01891.html
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00683.html
Thanks,
Andrew Pinski
More information about the Gcc
mailing list