mirror of
https://github.com/fmtlib/fmt.git
synced 2025-09-27 23:20:54 +02:00
Merge workarounds for bogus MSVC warnings
This commit is contained in:
@@ -133,17 +133,19 @@ FMT_FUNC auto write_loc(appender out, loc_value value,
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
FMT_FUNC void report_error(const char* message) {
|
FMT_FUNC void report_error(const char* message) {
|
||||||
|
#if FMT_MSC_VERSION || defined(__NVCC__)
|
||||||
|
// Silence unreachable code warnings in MSVC and NVCC because these
|
||||||
|
// are nearly impossible to fix in a generic code.
|
||||||
|
volatile bool b = true;
|
||||||
|
if (!b) return;
|
||||||
|
#endif
|
||||||
#if FMT_USE_EXCEPTIONS
|
#if FMT_USE_EXCEPTIONS
|
||||||
// Use FMT_THROW instead of throw to avoid bogus unreachable code warnings
|
// Use FMT_THROW instead of throw to avoid bogus unreachable code warnings
|
||||||
// from MSVC.
|
// from MSVC.
|
||||||
FMT_THROW(format_error(message));
|
FMT_THROW(format_error(message));
|
||||||
#else
|
#else
|
||||||
// Silence unreachable code warnings in MSVC.
|
fputs(message, stderr);
|
||||||
volatile bool b = true;
|
abort();
|
||||||
if (b) {
|
|
||||||
fputs(message, stderr);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -165,28 +165,14 @@ template <typename T> struct iterator_traits<fmt::basic_appender<T>> {
|
|||||||
};
|
};
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
#ifndef FMT_THROW
|
#ifdef FMT_THROW
|
||||||
# if FMT_USE_EXCEPTIONS
|
// Use the provided definition.
|
||||||
# if FMT_MSC_VERSION || defined(__NVCC__)
|
#elif FMT_USE_EXCEPTIONS
|
||||||
FMT_BEGIN_NAMESPACE
|
# define FMT_THROW(x) throw x
|
||||||
namespace detail {
|
#else
|
||||||
template <typename Exception> inline void do_throw(const Exception& x) {
|
# define FMT_THROW(x) \
|
||||||
// Silence unreachable code warnings in MSVC and NVCC because these
|
::fmt::detail::assert_fail(__FILE__, __LINE__, (x).what())
|
||||||
// are nearly impossible to fix in a generic code.
|
#endif
|
||||||
volatile bool b = true;
|
|
||||||
if (b) throw x;
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
# define FMT_THROW(x) detail::do_throw(x)
|
|
||||||
# else
|
|
||||||
# define FMT_THROW(x) throw x
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define FMT_THROW(x) \
|
|
||||||
::fmt::detail::assert_fail(__FILE__, __LINE__, (x).what())
|
|
||||||
# endif // FMT_USE_EXCEPTIONS
|
|
||||||
#endif // FMT_THROW
|
|
||||||
|
|
||||||
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
|
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
|
||||||
// integer formatter template instantiations to just one by only using the
|
// integer formatter template instantiations to just one by only using the
|
||||||
|
Reference in New Issue
Block a user