libfirm / cparser

C99 parser and frontend for libfirm
http://pp.ipd.kit.edu/firm
GNU General Public License v2.0
336 stars 38 forks source link

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

Open ludocode opened 3 years ago

ludocode commented 3 years ago
#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 8ec1a761bf62be1028632e5eceda425d9fbeb039. 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.