aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/limits
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-08-19 16:27:25 +0100
committerJonathan Wakely <jwakely@redhat.com>2020-08-19 16:49:07 +0100
commit386fd16c551188e20d5b1684b7139e4269f9a739 (patch)
tree8794a3bd26919abf77675933a9b48be10eae18dc /libstdc++-v3/include/std/limits
parent4432066509441cb6ec3e6688a523f9946e7b5d21 (diff)
downloadgcc-386fd16c551188e20d5b1684b7139e4269f9a739.zip
gcc-386fd16c551188e20d5b1684b7139e4269f9a739.tar.gz
gcc-386fd16c551188e20d5b1684b7139e4269f9a739.tar.bz2
libstdc++: Make __int128 meet integer-class requirements [PR 96042]
Because __int128 can be used as the difference type for iota_view, we need to ensure that it meets the requirements of an integer-class type. The requirements in [iterator.concept.winc] p10 include numeric_limits being specialized and giving meaningful answers. Currently we only specialize numeric_limits for non-standard integer types in non-strict modes. However, nothing prevents us from defining an explicit specialization for any implementation-defined type, so it doesn't matter whether std::is_integral<__int128> is true or not. This patch ensures that the numeric_limits specializations for signed and unsigned __int128 are defined whenever __int128 is available. It also makes the __numeric_traits and __int_limits helpers work for __int128, via a new __gnu_cxx::__is_integer_nonstrict trait. libstdc++-v3/ChangeLog: PR libstdc++/96042 * include/ext/numeric_traits.h (__is_integer_nonstrict): New trait which is true for 128-bit integers even in strict modes. (__numeric_traits_integer, __numeric_traits): Use __is_integer_nonstrict instead of __is_integer. * include/std/limits [__STRICT_ANSI__ && __SIZEOF_INT128__] (numeric_limits<__int128>, (numeric_limits<unsigned __int128>): Define. * testsuite/std/ranges/iota/96042.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/std/limits')
-rw-r--r--libstdc++-v3/include/std/limits10
1 files changed, 7 insertions, 3 deletions
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index f5e403b..20883ba 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
@@ -1477,8 +1477,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
= round_toward_zero;
};
-#if !defined(__STRICT_ANSI__)
-
#define __INT_N(TYPE, BITSIZE, EXT, UEXT) \
template<> \
struct numeric_limits<TYPE> \
@@ -1632,6 +1630,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __INT_N_U201103(TYPE)
#endif
+#if !defined(__STRICT_ANSI__)
#ifdef __GLIBCXX_TYPE_INT_N_0
__INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
__INT_N_201103 (__GLIBCXX_TYPE_INT_N_0),
@@ -1653,11 +1652,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__INT_N_U201103 (__GLIBCXX_TYPE_INT_N_3))
#endif
+#elif defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
+ __INT_N(__int128, 128,
+ __INT_N_201103 (__int128),
+ __INT_N_U201103 (__int128))
+#endif
+
#undef __INT_N
#undef __INT_N_201103
#undef __INT_N_U201103
-#endif
/// numeric_limits<float> specialization.
template<>