[llvm-dev] Compiling LLVM with GCC 5/6/7 and -std=c++1z fails due to use of std::char_traits constexpr
Dan Bailey via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 6 10:17:29 PDT 2020
Hi,
When trying to compile LLVM using GCC 5.1 => GCC 7.2 (inclusive) with
-std=c++1z, using StringRef errors due to the lack of a constexpr
std::char_traits<char>::length():
.../include/llvm/ADT/StringRef.h:85:44: *error*: call to non-constexpr
function ‘static std::size_t std::char_traits<char>::length(const
char_type*)’
return std::char_traits<char>::length(Str);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Looking into the issue, StringRef.h uses this logic to gate against using
constexpr char_traits:
#if *__cplusplus* > 201402L
return std::char_traits<char>::length(Str);
#elif ...
However for the GCC version range mentioned above, the -std=c++1z flag
generates __cplusplus 201500L or higher despite char_traits not being
constexpr.
I think the correct thing to do here might be to use the feature macro
instead:
#if *__cpp_lib_constexpr_char_traits*
return std::char_traits<char>::length(Str);
#elif ...
Any thoughts?
Thanks,
--
Dan Bailey | R&D | ILM Vancouver
danbailey at ilm.com | 415 746-XXXX Desk | 778 882-XXXX Cell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201006/e9fa4eb2/attachment.html>
More information about the llvm-dev
mailing list