This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[V3 PATCH] char extraction uses wrong cast


As discussed on the V3 list, the code for "is >> c" where c was specified
as a signed or signed char was wrong (static_cast's don't yield lvalues).
Hyman thoughtfully brought this to our attention.  Applied.


2001-02-06  Hyman Rosen  <Hyman.Rosen@kbcfp.com>
            Phil Edwards  <pme@sources.redhat.com>

	* include/bits/std_istream.h (op>> signed,unsigned char):  Must
	  use reinterpret_cast, not static_cast.


Index: include/bits/std_istream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_istream.h,v
retrieving revision 1.1
diff -u -3 -p -r1.1 std_istream.h
--- std_istream.h	2000/10/05 11:27:01	1.1
+++ std_istream.h	2001/02/06 15:50:14
@@ -240,12 +240,12 @@ namespace std {
   template<class _Traits>
     basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
-    { return (__in >> static_cast<char>(__c)); }
+    { return (__in >> reinterpret_cast<char&>(__c)); }
 
   template<class _Traits>
     basic_istream<char, _Traits>&
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
-    { return (__in >> static_cast<char>(__c)); }
+    { return (__in >> reinterpret_cast<char&>(__c)); }
 
   template<typename _CharT, typename _Traits>
     basic_istream<_CharT, _Traits>&

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]