<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - MSVC: implement /Zc:externConstexpr- to make constexpr globals internal by default"
href="https://bugs.llvm.org/show_bug.cgi?id=36413">36413</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MSVC: implement /Zc:externConstexpr- to make constexpr globals internal by default
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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: <a href="https://crbug.com/780056">https://crbug.com/780056</a> 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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>