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: unassignedclangb...@nondot.org Reporter: jmuizel...@mozilla.com CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs