[libcxx] r214371 - Fix numeric_limits<XXX>::is_modulo for signed arithmetic types. We were reporting true, for all arithmetic types, which is incorrect. Fix the tests which were wrong, too. This fixes PR#20158.

Marshall Clow mclow.lists at gmail.com
Wed Jul 30 18:18:05 PDT 2014


Author: marshall
Date: Wed Jul 30 20:18:05 2014
New Revision: 214371

URL: http://llvm.org/viewvc/llvm-project?rev=214371&view=rev
Log:
Fix numeric_limits<XXX>::is_modulo for signed arithmetic types. We were reporting true, for all arithmetic types, which is incorrect. Fix the tests which were wrong, too. This fixes PR#20158.

Modified:
    libcxx/trunk/include/limits
    libcxx/trunk/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp

Modified: libcxx/trunk/include/limits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits?rev=214371&r1=214370&r2=214371&view=diff
==============================================================================
--- libcxx/trunk/include/limits (original)
+++ libcxx/trunk/include/limits Wed Jul 30 20:18:05 2014
@@ -235,7 +235,7 @@ protected:
 
     static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
     static _LIBCPP_CONSTEXPR const bool is_bounded = true;
-    static _LIBCPP_CONSTEXPR const bool is_modulo = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value;
 
 #if __i386__ || __x86_64__
     static _LIBCPP_CONSTEXPR const bool traps = true;

Modified: libcxx/trunk/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp?rev=214371&r1=214370&r2=214371&view=diff
==============================================================================
--- libcxx/trunk/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp (original)
+++ libcxx/trunk/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp Wed Jul 30 20:18:05 2014
@@ -26,24 +26,24 @@ test()
 int main()
 {
     test<bool, false>();
-    test<char, true>();
-    test<signed char, true>();
+//    test<char, false>(); // don't know
+    test<signed char, false>();
     test<unsigned char, true>();
-    test<wchar_t, true>();
+//    test<wchar_t, false>(); // don't know
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     test<char16_t, true>();
     test<char32_t, true>();
 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
-    test<short, true>();
+    test<short, false>();
     test<unsigned short, true>();
-    test<int, true>();
+    test<int, false>();
     test<unsigned int, true>();
-    test<long, true>();
+    test<long, false>();
     test<unsigned long, true>();
-    test<long long, true>();
+    test<long long, false>();
     test<unsigned long long, true>();
 #ifndef _LIBCPP_HAS_NO_INT128
-    test<__int128_t, true>();
+    test<__int128_t, false>();
     test<__uint128_t, true>();
 #endif
     test<float, false>();





More information about the cfe-commits mailing list