This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
include/limits compile time overflow
- From: DJ Delorie <dj at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 2 Nov 2010 19:32:18 -0400
- Subject: include/limits compile time overflow
On 16-bit targets, include/limits fails to compile because this line:
static constexpr int max_digits10
= __glibcxx_max_digits10 (__DBL_MANT_DIG__);
results in computing 53 * 643 = 34,079, which exceeds 32767. GCC then
complains that the result is not computable at compile time.
The math comes from this:
// The fraction 643/2136 approximates log10(2) to 7 significant digits.
#define __glibcxx_digits10(T) \
(__glibcxx_digits (T) * 643 / 2136)
#define __glibcxx_max_digits10(T) \
(2 + (T) * 643 / 2136)
Can we use smaller numbers, or switch the 643 to 643L to appease gcc?