This macro should not be defined unconditionally. The macro isn't official (it was proposed in P0426R1 but doesn't appear in SD-6 or the drafts, or the C++2a working paper) so I haven't added any tests. Ideally we would have negative tests for each feature test macro, to make sure they aren't defined when the feature isn't available. I've done a review and this seems to be the only problem.
* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits): Only define for C++17 and above. Tested powerpc64le-linux, committed to trunk.
commit 8e1d107e8d81c7aa5d74246d00cdd791cbd4beb2 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri Jun 15 16:31:23 2018 +0100 Only define __cpp_lib_constexpr_char_traits for C++17 * include/bits/char_traits.h (__cpp_lib_constexpr_char_traits): Only define for C++17 and above. diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index 51cd321b8ae..7cc7c74e8fe 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -143,8 +143,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); } }; -#define __cpp_lib_constexpr_char_traits 201611 - template<typename _CharT> _GLIBCXX14_CONSTEXPR int char_traits<_CharT>:: @@ -216,7 +214,9 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#if __cplusplus > 201402 +#if __cplusplus >= 201703L +#define __cpp_lib_constexpr_char_traits 201611 + /** * @brief Determine whether the characters of a NULL-terminated * string are known at compile time. @@ -299,7 +299,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR int compare(const char_type* __s1, const char_type* __s2, size_t __n) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__builtin_constant_p(__n) && __constant_char_array_p(__s1, __n) && __constant_char_array_p(__s2, __n)) @@ -313,7 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR size_t length(const char_type* __s) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__constant_string_p(__s)) return __gnu_cxx::char_traits<char_type>::length(__s); #endif @@ -323,7 +323,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR const char_type* find(const char_type* __s, size_t __n, const char_type& __a) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__builtin_constant_p(__n) && __builtin_constant_p(__a) && __constant_char_array_p(__s, __n)) @@ -408,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR int compare(const char_type* __s1, const char_type* __s2, size_t __n) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__builtin_constant_p(__n) && __constant_char_array_p(__s1, __n) && __constant_char_array_p(__s2, __n)) @@ -423,7 +423,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR size_t length(const char_type* __s) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__constant_string_p(__s)) return __gnu_cxx::char_traits<char_type>::length(__s); else @@ -434,7 +434,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static _GLIBCXX17_CONSTEXPR const char_type* find(const char_type* __s, size_t __n, const char_type& __a) { -#if __cplusplus > 201402 +#if __cplusplus >= 201703L if (__builtin_constant_p(__n) && __builtin_constant_p(__a) && __constant_char_array_p(__s, __n))