diff --git a/include/fmt/base.h b/include/fmt/base.h index 83e36d6c..98b4d5c4 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -223,11 +223,6 @@ #else # define FMT_PRAGMA_CLANG(x) #endif -#if FMT_MSC_VERSION -# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) -#else -# define FMT_MSC_WARNING(...) -#endif // Enable minimal optimizations for more compact code in debug mode. FMT_PRAGMA_GCC(push_options) @@ -1741,9 +1736,12 @@ template class buffer { protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. - FMT_MSC_WARNING(suppress : 26495) constexpr buffer(grow_fun grow, size_t sz) noexcept - : size_(sz), capacity_(sz), grow_(grow) {} + : size_(sz), capacity_(sz), grow_(grow) { +#if FMT_MSC_VERSION + ptr_ = nullptr; // Suppress warning 26495. +#endif + } constexpr buffer(grow_fun grow, T* p = nullptr, size_t sz = 0, size_t cap = 0) noexcept diff --git a/include/fmt/format.h b/include/fmt/format.h index 57944612..c8d57ddd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -156,6 +156,12 @@ # define FMT_CONSTEXPR_STRING #endif +#if FMT_MSC_VERSION +# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) +#else +# define FMT_MSC_WARNING(...) +#endif + // GCC 4.9 doesn't support qualified names in specializations. namespace std { template struct iterator_traits> {