[PATCH] Update newlib so that it passes libc++'s tests
Joseph S. Myers
joseph@codesourcery.com
Tue Dec 17 08:01:00 GMT 2013
On Mon, 16 Dec 2013, JF Bastien wrote:
> - stdint.h: define WCHAR_MIN and WCHAR_MAX according to
> __WCHAR_UNSIGNED__ if it is provided, and correct the limit when
> unsigned (to 32 all-1 bits, not 31). Make sure stdint.h and wchar.h
> are in sync.
A value of 0 as WCHAR_MIN in the unsigned case has the wrong type if
wchar_t promotes to unsigned int / unsigned long (as opposed to, say, if
it's unsigned short promoting to signed int). glibc (2.18 and later) uses
(L'\0' + 0) (if __WCHAR_MIN__ isn't predefined) in the unsigned case to
get the correct promoted version of wchar_t, and similar constructs
involving + L'\0' for WCHAR_MAX to get the right type in those cases as
well.
In general, you need to make sure these constants have the right type,
being the promoted version of the type to which the macros refer,
including int/long differences even when those have the same
representation and alignment - and, for C++, distinguishing the distinct
wchar_t type from the type to which it promotes (the latter being the
right type for such constants) - not just the right value. In #if
expressions they need the same value and signedness as in normal C/C++
code (this means that (L'\0' - 1) is not a correct expression for
WCHAR_MAX in the unsigned case because in #if expressions it would
evaluate to UINTMAX_MAX).
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Newlib
mailing list