https://bugs.llvm.org/show_bug.cgi?id=50726

            Bug ID: 50726
           Summary: static initialization order not respected across
                    translation units for constructors with priority
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

It seems this has been reported before in
https://bugs.llvm.org/show_bug.cgi?id=12556 and
https://bugs.llvm.org/show_bug.cgi?id=26331 which were marked as wontfix.

Here is an example to repro the bug:
$ cat a.cpp

#include <cstdio>

struct test {
    test() {
        printf("i am constructed!\n");
    }
};

test test1;

__attribute__((constructor(0))) void cons_highestpri() {
    printf("i am also constructed highest pri!\n");
}


__attribute__((constructor(1010))) void cons_lopri() {
    printf("i am also constructed lopri!\n");
}

test test2;

int main() {

}


$ cat b.cpp
#include<cstdio>
__attribute__((constructor(101))) void cons_hipri() {
    printf("i am also constructed hipri!\n");
}


$ clang++ -flto=thin a.cpp b.cpp -O2 && ./a.out 

i am also constructed highest pri!
i am also constructed lopri!
i am constructed!
i am constructed!
i am also constructed hipri!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to