mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-29 21:31:05 +00:00
Fix more Visual Studio 2019 pedantic warnings (#1371)
* format-inl.h(444,1): warning C4804: '>>': unsafe use of type 'bool' in operation format.h(2808,1): warning C4127: conditional expression is constant * More fixes for VS2019 pedantic warnings * Fix "conditional expression is constant" VS2019 warning in more specific way * Use const_check to silence constexpr warning
This commit is contained in:
parent
00669427df
commit
21acc2af43
@ -46,7 +46,6 @@
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127) // conditional expression is constant
|
||||
# pragma warning(disable : 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
@ -441,7 +440,7 @@ class fp {
|
||||
std::numeric_limits<float>::digits - 1);
|
||||
if (min_normal_e > e) half_ulp <<= min_normal_e - e;
|
||||
upper = normalize<0>(fp(f + half_ulp, e));
|
||||
lower = fp(f - (half_ulp >> (f == implicit_bit && e > min_normal_e)), e);
|
||||
lower = fp(f - (half_ulp >> ((f == implicit_bit && e > min_normal_e) ? 1 : 0)), e);
|
||||
lower.f <<= lower.e - upper.e;
|
||||
lower.e = upper.e;
|
||||
}
|
||||
@ -939,7 +938,7 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
|
||||
uint64_t error, int exp, bool integral) {
|
||||
buf[size++] = digit;
|
||||
if (remainder >= error) return digits::more;
|
||||
if (GRISU_VERSION != 3) {
|
||||
if (const_check(GRISU_VERSION != 3)) {
|
||||
uint64_t d = integral ? diff : diff * data::powers_of_10_64[-exp];
|
||||
round(d, divisor, remainder, error);
|
||||
return digits::done;
|
||||
|
@ -192,6 +192,10 @@ FMT_END_NAMESPACE
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace internal {
|
||||
|
||||
// A helper function to suppress bogus "conditional expression is constant"
|
||||
// warnings.
|
||||
template <typename T> inline T const_check(T value) { return value; }
|
||||
|
||||
// A fallback implementation of uintptr_t for systems that lack it.
|
||||
struct fallback_uintptr {
|
||||
unsigned char value[sizeof(void*)];
|
||||
@ -2807,7 +2811,7 @@ void internal::basic_writer<Range>::write_fp(T value,
|
||||
int precision = specs.precision >= 0 || !specs.type ? specs.precision : 6;
|
||||
unsigned options = 0;
|
||||
if (handler.fixed) options |= grisu_options::fixed;
|
||||
if (sizeof(value) == sizeof(float)) options |= grisu_options::binary32;
|
||||
if (const_check(sizeof(value) == sizeof(float))) options |= grisu_options::binary32;
|
||||
bool use_grisu =
|
||||
USE_GRISU &&
|
||||
(specs.type != 'a' && specs.type != 'A' && specs.type != 'e' &&
|
||||
|
@ -16,10 +16,6 @@
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace internal {
|
||||
|
||||
// A helper function to suppress bogus "conditional expression is constant"
|
||||
// warnings.
|
||||
template <typename T> inline T const_check(T value) { return value; }
|
||||
|
||||
// Checks if a value fits in int - used to avoid warnings about comparing
|
||||
// signed and unsigned integers.
|
||||
template <bool IsSigned> struct int_checker {
|
||||
|
Loading…
Reference in New Issue
Block a user