From 1d2d479afa47f0c2de834e699c62315400021acc Mon Sep 17 00:00:00 2001 From: Florin Iucha Date: Sat, 15 Dec 2018 23:46:36 -0500 Subject: [PATCH] Enable conversion warning checking for pedantic build --- CMakeLists.txt | 5 +++-- include/fmt/printf.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7709a9b8..220ec9aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") -Wcast-align -Wnon-virtual-dtor -Wctor-dtor-privacy -Wdisabled-optimization -Winvalid-pch -Woverloaded-virtual + -Wconversion -Wno-ctor-dtor-privacy -Wno-dangling-else - -Wno-format-nonliteral -Wno-sign-conversion -Wno-shadow -Wno-unused-local-typedefs) + -Wno-format-nonliteral -Wno-shadow -Wno-unused-local-typedefs) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnoexcept) endif () @@ -92,7 +93,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(PEDANTIC_COMPILE_FLAGS -Wall -Wextra -pedantic) + set(PEDANTIC_COMPILE_FLAGS -Wall -Wextra -pedantic -Wconversion -Wno-sign-conversion) check_cxx_compiler_flag(-Wzero-as-null-pointer-constant HAS_NULLPTR_WARNING) if (HAS_NULLPTR_WARNING) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 606cea48..6f2715d9 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -631,7 +631,7 @@ void basic_printf_context::format() { format_arg arg = get_arg(it, arg_index); if (spec.has(HASH_FLAG) && visit_format_arg(internal::is_zero_int(), arg)) - spec.flags &= ~internal::to_unsigned(HASH_FLAG); + spec.flags = static_cast(spec.flags & (~internal::to_unsigned(HASH_FLAG))); if (spec.fill_ == '0') { if (arg.is_arithmetic()) spec.align_ = ALIGN_NUMERIC;