recent work on include/bits/locale_facets.h

Jerry Quinn jlquinn@optonline.net
Tue Dec 30 03:09:00 GMT 2003


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;
        }
  



More information about the Libstdc++ mailing list