https://llvm.org/bugs/show_bug.cgi?id=30323
Bug ID: 30323
Summary: Header "limits": const int max_digits10 calculation
won't compile if "int" is 16 bit long
Product: libc++
Version: 3.8
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
For type float, double or long double, the calculation of max_digits10 is:
static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000);
This won't compile when type "int" is only 16 bit long (for example, when
compiling for target msp430), since "digits * 30103" is then out of range.
(When digits is 24, digits * 30103 is 722472 >= 32767.
As a fix, the calculation could be made as "long" and then casted to "int".
E.g.
static _LIBCPP_CONSTEXPR const int max_digits10 =
static_cast<int>(2L+(static_cast<long>(digits) * 30103L)/100000L);
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs