This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]