<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 - constexpr std::string_view global no longer compiles"
href="https://bugs.llvm.org/show_bug.cgi?id=39108">39108</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>constexpr std::string_view global no longer compiles
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jorg.brown@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>clang 7.0 accepted global variables of type std::string_view, even if declared
constexpr.
The current trunk of clang (clang version 8.0.0 (trunk 343155) ) does not.
For that matter, std::string::traits_type::length also does not.
Repro: this compiles under 7.0 but not 8.0.0 / trunk 343155:
#include <string>
constexpr size_t one = std::string::traits_type::length("1");
size_t return_1() { return one; }
Giving this error:
<source>:3:18: error: constexpr variable 'one' must be initialized by a
constant expression
constexpr size_t one = std::string::traits_type::length("1");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:3:24: note: non-constexpr function 'length' cannot be used in a
constant expression
constexpr size_t one = std::string::traits_type::length("1");
^
/opt/compiler-explorer/gcc-7.2.0/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/char_traits.h:268:7:
note: declared here
length(const char_type* __s)
^
Obligatory godbolt link: <a href="https://gcc.godbolt.org/z/yOmaJr">https://gcc.godbolt.org/z/yOmaJr</a></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>