[llvm-bugs] [Bug 36413] New: MSVC: implement /Zc:externConstexpr- to make constexpr globals internal by default
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 16 15:32:13 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36413
Bug ID: 36413
Summary: MSVC: implement /Zc:externConstexpr- to make constexpr
globals internal by default
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: rnk at google.com
CC: llvm-bugs at lists.llvm.org
MSVC has a bug where some constexpr globals are given internal (static) linkage
when the standard requires external linkage. Here is an example:
$ cat t.cpp
extern int some_int;
constexpr const int &int_ref = some_int;
int useit() { return int_ref; }
$ cl -nologo -c t.cpp && dumpbin -symbols t.obj | grep int_ref
t.cpp
009 00000000 SECT3 notype Static | ?int_ref@@3AEBHEB (int const &
const int_ref)
$ clang-cl -c t.cpp && dumpbin -symbols t.obj | grep int_ref
00C 00000000 SECT4 notype External | ?int_ref@@3AEBHEB (int const &
const int_ref)
See 'Static' vs. 'External'.
This lead to link errors when using certain parts of the 10.0.16299.0 Windows
SDK in Chromium, originally reported here: https://crbug.com/780056 See the
comments relating to MIDL_CONST_ID and windows.ui.viewmanagement.h.
MIDL appears to contain (or generate) this macro:
#pragma push_macro("MIDL_CONST_ID")
#if !defined(_MSC_VER) || (_MSC_VER >= 1910)
#define MIDL_CONST_ID constexpr const
#else
#define MIDL_CONST_ID const __declspec(selectany)
#endif
It seems that the authors expected 'constexpr' to imply __declspec(selectany),
which is odd, because MSVC doesn't do that at all, it just makes the thing
static, not comdat.
MSVC has a flag that disables this behavior, /Zc:externConstexpr, but I have to
update VS before I can experiment with it.
--
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/20180216/85e95784/attachment.html>
More information about the llvm-bugs
mailing list