From 22cfa65a3fb2e09c916a7f0924319e68fec60b37 Mon Sep 17 00:00:00 2001 From: medithe <40990424+medithe@users.noreply.github.com> Date: Mon, 27 Aug 2018 08:43:56 +0200 Subject: [PATCH] Remove conversion compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling with g++8, I get the following two errors: include/fmt/format-inl.h:400:29: error: conversion from ‘int’ to ‘char’ may change value [-Werror=conversion] buffer[size++] = zero + static_cast(digit); ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ include/fmt/format-inl.h:416:28: error: conversion from ‘int’ to ‘char’ may change value [-Werror=conversion] buffer[size++] = '0' + digit; ~~~~^~~~~~~ With this change, the errors are gone. --- include/fmt/format-inl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 98aaee26..ab4e65d5 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -395,7 +395,7 @@ FMT_FUNC void grisu2_gen_digits( FMT_ASSERT(false, "invalid number of digits"); } if (digit != 0 || size != 0) - buffer[size++] = '0' + static_cast(digit); + buffer[size++] = static_cast('0' + static_cast(digit)); --kappa; uint64_t remainder = (static_cast(hi) << -one.e) + lo; if (remainder <= delta) { @@ -410,7 +410,7 @@ FMT_FUNC void grisu2_gen_digits( delta *= 10; char digit = static_cast(lo >> -one.e); if (digit != 0 || size != 0) - buffer[size++] = '0' + digit; + buffer[size++] = static_cast('0' + digit); lo &= one.f - 1; --kappa; if (lo < delta) {