#1307 __naked functions that return function pointers

closed
nobody
None
5
2007-07-15
2007-03-12
No

typedef void (*func)(void);

func GetFunc(void) __naked
{
_asm

; some assembler code

_endasm;
}

void Caller(void)
{
GetFunc()();
}

The above mentioned program leads to the error message
"error 12: called object is not a function".

Some tests indicated that the __naked modifier confuses the compiler about the return value of GetFunc().
If I change Getfunc() to not use __naked it compiles OK:

func GetFunc(void)
{
return (func)0;
}

I tested this with 2.6.0 and the latest snapshot.

Discussion

  • Robert Larice

    Robert Larice - 2007-07-13

    Logged In: YES
    user_id=1840151
    Originator: NO

    Ralf Guetlein,
    i've tried svn version #4870 and #4882 with
    sdcc -c -mmcs51
    and "ret" for "some assembler code"
    both versions worked well.

    what version did you try ?
    what was the exact command line for sdcc ?

    Robert Larice

     
  • Ralf Guetlein

    Ralf Guetlein - 2007-07-15

    Logged In: YES
    user_id=145736
    Originator: YES

    Robert,

    I found the reported bug on 2.6.0 and a snapshot from February this year.
    Now I can tell the error is gone in 2.7.0

    Regards,
    Ralf

     
  • Ralf Guetlein

    Ralf Guetlein - 2007-07-15
    • status: open --> closed
     
  • Maarten Brock

    Maarten Brock - 2007-07-15

    Logged In: YES
    user_id=888171
    Originator: NO

    Thanks for checking. To make sure it will not resurface again I've added a testcase to the regression tests in #4885.

     

Log in to post a comment.