boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
433 stars 74 forks source link

Conversion warning at to_dec_array.hpp:34 #69

Closed Caian closed 5 years ago

Caian commented 5 years ago

I am receiving the following warning when compiling with -Wconversion:

boost/stacktrace/detail/to_dec_array.hpp: In function ‘boost::array<char, 40ul> boost::stacktrace::detail::to_dec_array(std::size_t)’:
boost/stacktrace/detail/to_dec_array.hpp:34:31: warning: conversion to ‘char’ from ‘std::size_t {aka long unsigned int}’ may alter its value [-Wconversion]
         ret[digits - i] = '0' + (value % 10);

Although it is not an error, I think a static_cast can be used to avoid unnecessary compiler output:

ret[digits - i] = static_cast<char>('0' + (value % 10));
apolukhin commented 5 years ago

Many thanks for the report!