[llvm-bugs] [Bug 39108] New: constexpr std::string_view global no longer compiles
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 28 00:43:49 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39108
Bug ID: 39108
Summary: constexpr std::string_view global no longer compiles
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: release blocker
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: jorg.brown at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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: https://gcc.godbolt.org/z/yOmaJr
--
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/20180928/90835812/attachment.html>
More information about the llvm-bugs
mailing list