Menu

#2664 Wrong number of parameters

closed-fixed
None
Front-end
5
2022-08-03
2017-10-08
No

The function

void (*sigset(int signo, void (*func)(int signo)))(int signo)
{
    return(0);
}

has two parameters. But SDCC compiles it as if the parameter func was not there. Inside the function, any use of func makes SDCC complain about an undefined identifier. On calls to sigset(), SDCC accepts only a single int parameter.

Philipp

Related

Feature Requests: #809
Wiki: SDCC 4.3.0 Release
Wiki: SDCC-STD-UX

Discussion

  • Philipp Klaus Krause

    This bug is present in at least SDCC 3.6.9 #10034 and 3.6.9 #10039.
    In revision [r10039], I added a disabled test for this bug in tests/bug-2556.c.

    Philipp

     

    Last edit: Philipp Klaus Krause 2017-10-08
  • Philipp Klaus Krause

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -7,6 +7,6 @@
     }
     ~~~~
    
    -has two parameters. But SDCC compiles it as if the parameter func was not there. Inside the function, any use of func makes SDCC complain about an undefined identifier. On calls to sigset(), SDCC acepts only a singel int parameter.
    +has two parameters. But SDCC compiles it as if the parameter func was not there. Inside the function, any use of func makes SDCC complain about an undefined identifier. On calls to sigset(), SDCC acecpts only a single int parameter.
    
     Philipp
    
     
  • Philipp Klaus Krause

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -7,6 +7,6 @@
     }
     ~~~~
    
    -has two parameters. But SDCC compiles it as if the parameter func was not there. Inside the function, any use of func makes SDCC complain about an undefined identifier. On calls to sigset(), SDCC acecpts only a single int parameter.
    +has two parameters. But SDCC compiles it as if the parameter func was not there. Inside the function, any use of func makes SDCC complain about an undefined identifier. On calls to sigset(), SDCC accepts only a single int parameter.
    
     Philipp
    
     
  • Philipp Klaus Krause

    Looking at this a bit more closely, in particular at the AST:
    Apparently, the function sigset gets the parameters meant for the function returned by sigset. So SDCC treats sigset as if it had a single int parameter. On the other hand, the function returned by sigset doesn't have parameters in the AST at all - not even void.

    P.S.: A smaller example:

    void (*f(int i))(void)
    {
        return 0;
    }
    

    f should be a function taking an int and returning a pointer to a function taking void and returning void. But SDCC treats it as a function taking void and returning a function with no parameters.

     

    Last edit: Philipp Klaus Krause 2022-04-19
    • Philipp Klaus Krause

      Looking at what happens in the parser, the int parameter is first correctly attached to f, but then the void is also attached to f (overwriting the earlier int) instead of to the return type of f.

       
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    Fixed in the parser branch in [r13620].

     

    Related

    Commit: [r13620]

  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in [r13625].

     

    Related

    Commit: [r13625]


Log in to post a comment.