[llvm-bugs] [Bug 38326] New: init_priority(65535) behavior differs from g++

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 26 01:23:39 PDT 2018


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

            Bug ID: 38326
           Summary: init_priority(65535) behavior differs from g++
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stephane.zimmermann at trust-in-soft.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 20602
  --> https://bugs.llvm.org/attachment.cgi?id=20602&action=edit
Test case

The following program:
extern "C" int printf(const char *, ...);

struct Foo {
    Foo(int x) { printf("INIT: %d\n", x); }
};

Foo f(1);
Foo f2(2);
Foo f3(3);

__attribute__((init_priority(101)))
Foo g0(101);

__attribute__((init_priority(65534)))
Foo g(65534);

__attribute__((init_priority(65535)))
Foo h(65535);

int main(void) {
    return 0;
}

- when compiled with clang++ (5.0.0) displays:
INIT: 101
INIT: 65534
INIT: 65535
INIT: 1
INIT: 2
INIT: 3

- when compiled with g++ (5.4.0) displays:
INIT: 101
INIT: 65534
INIT: 1
INIT: 2
INIT: 3
INIT: 65535

g++ seems to consider that init_priority 655535 happens after standard dynamic
initialization.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180726/750e9830/attachment-0001.html>


More information about the llvm-bugs mailing list