mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-25 12:05:06 +08:00
7f851c3341
The expression used to calculate the maximum value for an integer type assumes that the number of bits in the value representation is always sizeof(T) * CHAR_BIT. This is not true for the __int20 type on msp430, which has only 20 bits in the value representation but 32 bits in the object representation. This causes an integer overflow in a constant expression, which is ill-formed. This problem was already solved by DJ for std::numeric_limits<__int20> by generalizing the helper macros to use a specified number of bits instead of assuming sizeof(T) * CHAR_BIT. Then the INT_N_n types can specify the number of bits using the __GLIBCXX_BITSIZE_INT_N_n macros that the compiler defines. I'm using a slightly different approach here. I've replaced the helper macros entirely, and just expanded the calculations in the initializers for the static data members. By reordering the data members we can reuse __is_signed and __digits in the other initializers. This removes the repetition of expanding __glibcxx_signed(T) and __glibcxx_digits(T) multiple times in each initializer. The __is_integer_nonstrict trait now defines a new constant, __width, which is sizeof(T) * CHAR_BIT by default (defined as an enumerator so that no storage is needed for a static data member). By specializing __is_integer_nonstrict for the INT_N types that have padding bits, we can provide the correct width via the __GLIBCXX_BITSIZE_INT_N_n macros. libstdc++-v3/ChangeLog: PR libstdc++/97798 * include/ext/numeric_traits.h (__glibcxx_signed) (__glibcxx_digits, __glibcxx_min, __glibcxx_max): Remove macros. (__is_integer_nonstrict::__width): Define new constant. (__numeric_traits_integer): Define constants in terms of each other and __is_integer_nonstrict::__width, rather than the removed macros. (_GLIBCXX_INT_N_TRAITS): Macro to define explicit specializations for non-standard integer types. |
||
---|---|---|
.. | ||
config | ||
doc | ||
include | ||
libsupc++ | ||
po | ||
python | ||
scripts | ||
src | ||
testsuite | ||
acinclude.m4 | ||
aclocal.m4 | ||
ChangeLog | ||
ChangeLog-1998 | ||
ChangeLog-1999 | ||
ChangeLog-2000 | ||
ChangeLog-2001 | ||
ChangeLog-2002 | ||
ChangeLog-2003 | ||
ChangeLog-2004 | ||
ChangeLog-2005 | ||
ChangeLog-2006 | ||
ChangeLog-2007 | ||
ChangeLog-2008 | ||
ChangeLog-2009 | ||
ChangeLog-2010 | ||
ChangeLog-2011 | ||
ChangeLog-2012 | ||
ChangeLog-2013 | ||
ChangeLog-2014 | ||
ChangeLog-2015 | ||
ChangeLog-2016 | ||
ChangeLog-2017 | ||
ChangeLog-2018 | ||
ChangeLog-2019 | ||
config.h.in | ||
configure | ||
configure.ac | ||
configure.host | ||
crossconfig.m4 | ||
fragment.am | ||
linkage.m4 | ||
Makefile.am | ||
Makefile.in | ||
README |
file: libstdc++-v3/README New users may wish to point their web browsers to the file index.html in the 'doc/html' subdirectory. It contains brief building instructions and notes on how to configure the library in interesting ways.