[llvm-bugs] [Bug 26210] New: clang-cl and msvc-cl disagree about static initialization

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 19 10:54:35 PST 2016


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

            Bug ID: 26210
           Summary: clang-cl and msvc-cl disagree about static
                    initialization
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jmuizelaar at mozilla.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When compiling a function like this:
inline const T *Ops() {
    static int k;
    static const T sOps = true ? 0 : &k;
    return &sOps;
}

msvc puts sOps in a read-write section, while clang puts sOps in a read-only
section. If the code for Ops() is not included in the object file from clang,
the linker can pick the read-only sOps from clang and Ops() implementation from
msvc. When the msvc Ops() runs it will crash trying to write to sOps.

I've put up a repo that reproduces this issue here:
https://github.com/jrmuizel/read-only-symbol-crash/

We're currently trying to bisect some clang related compilation issues and this
is preventing us from linking object files from clang and cl together. I
suspect using the clang front end on top of cl2 backend will also suffer from
this interoperability issue.

-- 
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/20160119/94182907/attachment.html>


More information about the llvm-bugs mailing list