[flang-commits] [flang] [llvm] [Flang] Introduce common::numeric_limits (PR #228108)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Tue Oct 6 03:27:56 PDT 2026


================
@@ -113,6 +114,34 @@ static void TestVsNative() {
 }
 #endif
 
+template <typename T> static void TestNumericLimitsEquivalence() {
+  using Std = std::numeric_limits<T>;
+  using Detail = Fortran::common::detail::numeric_limits<T>;
+  using Common = Fortran::common::numeric_limits<T>;
+
+  // Our implementation in Detail must be equivalent to Std
+  // (if Std supports __int128).
+  if constexpr (Std::is_specialized) {
+    TEST(Detail::is_specialized == Std::is_specialized);
+    TEST(Detail::is_signed == Std::is_signed);
+    TEST(Detail::is_integer == Std::is_integer);
+    TEST(Detail::min() == Std::min());
+    TEST(Detail::max() == Std::max());
+    TEST(Detail::lowest() == Std::lowest());
+  } else {
+    llvm::outs() << "std::numeric_limits is not specialized for this type\n";
+  }
+
+  // Common may refer to either Std to Detail; in either case it must be
----------------
eugeneepshteyn wrote:

typo: "either Std to Detail" -> "either Std or Detail"

https://github.com/llvm/llvm-project/pull/228108


More information about the flang-commits mailing list