Menu ▾ ▴

#496 Casting void * to pointer to function

closed-fixed
5
12 hours ago
2003-04-06
No

void *p;
extern void g(int (*h)(int));

void f() {
g((int (*)(int))p);
}

/*
casting5.c:6: error: too few parameters
casting5.c:6: error: incompatible types
from type 'int generic* '
to type 'int function code* '
casting5.c:6: error: code not generated for 'f' due
to previous errors
*/
~

Related

Bugs: #294

Discussion

  • Maarten Brock

    Maarten Brock - 2004-03-23

    Logged In: YES
    user_id=888171

    Anyone have any idea if the original cast is legal C?

    On the other hand, the next fragment works perfectly fine
    and produces the same code as I would expect from the
    former if it did not generate an error.

    void *p;
    extern void g(int (*h)(int));

    void f() {
    int (*fp)(int) = p;
    g(fp);
    }

    Greets,
    Maarten

     
  • Bernhard Held

    Bernhard Held - 2006-01-27

    Logged In: YES
    user_id=203539

    Fixed in SDCC.y 1.105, sdcc build 1197

     
  • Bernhard Held

    Bernhard Held - 2006-01-27
    • milestone: --> fixed
    • assigned_to: nobody --> bernhardheld
    • status: open --> closed-fixed
     
  • Maarten Brock

    Maarten Brock - 12 hours ago

    For reference: this was applied in [r4024] by Bernhard.

     

Log in to post a comment.