This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why does casting a function generate a run-time abort?
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: zlaski at apple dot com (Ziemowit Laski)
- Cc: gcc at gcc dot gnu dot org (gcc List)
- Date: Thu, 17 Jun 2004 22:03:03 -0400 (EDT)
- Subject: Re: Why does casting a function generate a run-time abort?
> 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