This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ctype_members.cc Comparison Always True
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>, Martin Sebor <msebor at gmail dot com>
- Date: Wed, 19 Aug 2015 11:12:41 +0100
- Subject: Re: ctype_members.cc Comparison Always True
- Authentication-results: sourceware.org; auth=none
- References: <55BFB455 dot 8020208 at oarcorp dot com> <55D3E6E6 dot 8000209 at gmail dot com>
On 19 August 2015 at 03:16, Martin Sebor wrote:
> On 08/03/2015 12:35 PM, Joel Sherrill wrote:
>>
>> Hi
>>
>> Just noticed this building the head for arm-rtems4.11. Should
>> the first comparison be eliminated and, maybe, a comment added?
>>
>> ctype_members.cc:216:14: warning: comparison of unsigned expression >= 0
>> is always true [-Wtype-limits]
>> if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
>> ^
>> ctype_members.cc: In member function 'virtual const wchar_t*
>> std::ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*, char,
>> char*) const':
>> ctype_members.cc:230:14: warning: comparison of unsigned expression >= 0
>> is always true [-Wtype-limits]
>> if (*__lo >= 0 && *__lo < 128)
>
>
> Unconditionally removing the test alone wouldn't be right for targets
> where wchar_t is a signed type. But casting the result to an unsigned
> type with as much precision as wchar_t should make it possible to
> remove it safely.
Joel, please discuss this on the libstdc++ list instead so the
relevant people notice it.