This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[V3 PATCH] char extraction uses wrong cast
- To: gcc-patches at gcc dot gnu dot org
- Subject: [V3 PATCH] char extraction uses wrong cast
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Tue, 6 Feb 2001 11:08:30 -0500
- Cc: libstdc++ at gcc dot gnu dot org
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>&