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

__attribute__((constructor)) is ignored on static functions #54

Open
ludocode opened this issue Sep 26, 2020 · 0 comments
Open

__attribute__((constructor)) is ignored on static functions #54

ludocode opened this issue Sep 26, 2020 · 0 comments

Comments

@ludocode
Copy link

#include <stdio.h>

const char* a = "nope";

__attribute__((__constructor__)) static void foo(void) {
    a = "yep";
}

int main(void) {
    puts(a);
}

Gives compiler warning "'void foo(void)' defined but not used" and resulting binary prints "nope" under cparser 8ec1a76. Prints "yep" under GCC and Clang. Removing the keyword static fixes it.

Is cparser still maintained? There haven't been any commits in 5 months or resolved issues in over a year. It doesn't look like there's much point in logging these bugs; mostly I'm just doing it so that other people can find them in case they run into the same bug.

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

No branches or pull requests

1 participant