[libcxx-commits] [libcxx] [libcxx] coerce formatter literal to int32_t (PR #87738)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 4 23:20:09 PDT 2024


================
@@ -690,7 +690,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par
       // Let P equal the precision if nonzero, 6 if the precision is not
       // specified, or 1 if the precision is 0. Then, if a conversion with
       // style E would have an exponent of X:
-      int __p = std::max(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
+      int __p = std::max(int32_t(1), (__specs.__has_precision() ? __specs.__precision_ : 6));
----------------
mordante wrote:

This should work too and based in the type of `__p` this looks more natural.
```suggestion
      int __p = std::max<int>(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
```
Can you verify this works for you?

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


More information about the libcxx-commits mailing list