This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
recent work on include/bits/locale_facets.h
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Dec 2003 22:09:29 -0500
- Subject: recent work on include/bits/locale_facets.h
- References: <200312291659.hBTGx9F7070106@latour.rsch.comm.mot.com>
Loren James Rittle writes:
> Would someone that recently worked on include/bits/locale_facets.h
> consider the direct use of a char (which may be unsigned or signed,
> depending on platform) to index both _M_widen and _M_narrow in the new
> code path.
>
> The daily tester on ref5 compiles testsuite/17_intro/headers.cc with
> -Wall -Wsystem-headers and thus caught this issue:
>
> [...]locale_facets.h:881: warning: array subscript has type `char'
> [...]locale_facets.h:937: warning: array subscript has type `char'
> [...]locale_facets.h:937: warning: array subscript has type `char'
> [...]locale_facets.h:939: warning: array subscript has type `char'
>
> Regards,
> Loren
Committed as obvious.
2003-12-29 Jerry Quinn <jlquinn@optonline.net>
* include/bits/locale_facets.h (ctype.narrow,widen): Add cast.
*** locale_facets.h.~1.79.~ Sun Dec 21 19:51:03 2003
--- locale_facets.h Mon Dec 29 21:54:59 2003
***************
*** 878,884 ****
char_type
widen(char __c) const
{
! if (_M_widen_ok) return _M_widen[__c];
this->_M_widen_init();
return this->do_widen(__c);
}
--- 878,884 ----
char_type
widen(char __c) const
{
! if (_M_widen_ok) return _M_widen[static_cast<unsigned char>(__c)];
this->_M_widen_init();
return this->do_widen(__c);
}
***************
*** 934,942 ****
char
narrow(char_type __c, char __dfault) const
{
! if (_M_narrow[__c]) return _M_narrow[__c];
const char __t = do_narrow(__c, __dfault);
! if (__t != __dfault) _M_narrow[__c] = __t;
return __t;
}
--- 934,943 ----
char
narrow(char_type __c, char __dfault) const
{
! if (_M_narrow[static_cast<unsigned char>(__c)])
! return _M_narrow[static_cast<unsigned char>(__c)];
const char __t = do_narrow(__c, __dfault);
! if (__t != __dfault) _M_narrow[static_cast<unsigned char>(__c)] = __t;
return __t;
}