Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var a=function(){var x=0;return (function(){return x;})}; #45

Open
zaoqi-unsafe opened this issue Jun 21, 2019 · 1 comment
Open

var a=function(){var x=0;return (function(){return x;})}; #45

zaoqi-unsafe opened this issue Jun 21, 2019 · 1 comment
Labels

Comments

@zaoqi-unsafe
Copy link

var a=function(){var x=0;return (function(){return x;})};
a()();
typedef short int16_t;

struct a_func_t {
    int16_t (*func)(struct a_func_t *);
    int16_t x;
};

static struct a_func_t * (*a)();
int16_t func(int16_t x)
{
    return x;

}
struct a_func_t * a_func()
{
    int16_t x;
    x = 0;
    return (func);

}

int main(void) {
    a = a_func;
    a()(x);

    return 0;
}
@zaoqi-unsafe
Copy link
Author


jdoodle.c: In function 'a_func':
jdoodle.c:18:12: warning: returning 'int16_t (*)(int16_t)' {aka 'short int (*)(short int)'} from a function with incompatible return type 'struct a_func_t *' [-Wincompatible-pointer-types]
     return (func);
            ^
jdoodle.c: In function 'main':
jdoodle.c:24:9: error: 'x' undeclared (first use in this function)
     a()(x);
         ^
jdoodle.c:24:9: note: each undeclared identifier is reported only once for each function it appears in
jdoodle.c:24:5: error: called object is not a function or function pointer
     a()(x);
     ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants