From 94b58e6b712cb3b4e97e5b310779d468bbade136 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 | 9 +++++---- include/fmt/printf.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7709a9b8..ce9dbf95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,10 +74,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") -Wcast-align -Wnon-virtual-dtor -Wctor-dtor-privacy -Wdisabled-optimization -Winvalid-pch -Woverloaded-virtual - -Wno-ctor-dtor-privacy -Wno-dangling-else - -Wno-format-nonliteral -Wno-sign-conversion -Wno-shadow -Wno-unused-local-typedefs) + -Wconversion + -Wno-ctor-dtor-privacy -Wno-format-nonliteral -Wno-shadow) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) - set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnoexcept) + set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnoexcept + -Wno-dangling-else -Wno-unused-local-typedefs) endif () if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wdouble-promotion @@ -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;