[V3 PATCH] char extraction uses wrong cast
Phil Edwards
pedwards@disaster.jaj.com
Tue Feb 6 07:57:00 GMT 2001
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>&
More information about the Libstdc++
mailing list