Dan Bailey via llvm-dev
2020-Oct-06 17:17 UTC
[llvm-dev] Compiling LLVM with GCC 5/6/7 and -std=c++1z fails due to use of std::char_traits constexpr
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>
David Blaikie via llvm-dev
2020-Nov-02 17:41 UTC
[llvm-dev] Compiling LLVM with GCC 5/6/7 and -std=c++1z fails due to use of std::char_traits constexpr
+ Eric (for standard library knowledge) & Richard (for general C++-ery). I can't say I know much about __cpp_lib_constexpr_char_traits - got any reference on how widely supported/implemented that is? On Tue, Oct 6, 2020 at 10:17 AM Dan Bailey via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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 > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201102/865d2355/attachment.html>