This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Use WCHAR_UNSIGNED when interpreting wide charconsts
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Cc: <gcc-patches at gcc dot gnu dot org>, Zack Weinberg <zack at codesourcery dot com>
- Date: Sun, 24 Feb 2002 11:49:39 +0000 (GMT)
- Subject: Re: Use WCHAR_UNSIGNED when interpreting wide charconsts
On Sun, 24 Feb 2002, Neil Booth wrote:
> +#if L'\x0' - 1 < 0
That is the right test for the preprocessor (since all unsigned types are
treated as uintmax_t - at least in C99, C90 is silent about narrow
unsigned types here, C++ also seems only to mention int and unsigned int
but says that bool subexpressions are promoted). (The problem of whether
the type of the constant is signed or unsigned only applies directly for
wide character constants, since in C (but not C++) narrow constants have
type int.)
> + if (c - 1 > 0)
> + abort ();
This isn't the correct test for the compiler - if wchar_t is unsigned
short then it will get promoted to int in expressions. Test (wchar_t)-1
instead.
--
Joseph S. Myers
jsm28@cam.ac.uk