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]

Minor libstdc++ fix



1 << 16 overflows on 16bit int targets.

This cleans up a few initializations in libstdc++ so that they
work properly on such targets (via 1L << 16).

There is likely other code in libstdc++-v3 which is not 16bit int
clean.  Fun fun fun.

        * include/bits/ios_base.h (_S_ios_fmtflags_end): Initialize
        cleanly targets with 16bit ints.
        (_S_ios_openmode_end): Similarly.
        (_S_ios_iostate_end): Similarly.
        (_S_ios_Seekdir_end): Similarly.
Index: include/bits/ios_base.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/ios_base.h,v
retrieving revision 1.7
diff -c -3 -p -r1.7 ios_base.h
*** ios_base.h	2001/01/17 07:44:56	1.7
--- ios_base.h	2001/02/02 22:52:27
*************** namespace std {
*** 40,46 ****
    // as permitted (but not required) in the standard, in order to provide
    // better type safety in iostream calls.  A side effect is that
    // expressions involving them are no longer compile-time constants.
!   enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1 << 16 };
  
    inline _Ios_Fmtflags 
    operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
--- 40,46 ----
    // as permitted (but not required) in the standard, in order to provide
    // better type safety in iostream calls.  A side effect is that
    // expressions involving them are no longer compile-time constants.
!   enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1L << 16 };
  
    inline _Ios_Fmtflags 
    operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
*************** namespace std {
*** 71,77 ****
    { return _Ios_Fmtflags(~static_cast<int>(__a)); }
  
  
!   enum _Ios_Openmode { _M_ios_openmode_end = 1 << 16 };
  
    inline _Ios_Openmode 
    operator&(_Ios_Openmode __a, _Ios_Openmode __b)
--- 71,77 ----
    { return _Ios_Fmtflags(~static_cast<int>(__a)); }
  
  
!   enum _Ios_Openmode { _M_ios_openmode_end = 1L << 16 };
  
    inline _Ios_Openmode 
    operator&(_Ios_Openmode __a, _Ios_Openmode __b)
*************** namespace std {
*** 102,108 ****
    { return _Ios_Openmode(~static_cast<int>(__a)); }
  
  
!   enum _Ios_Iostate { _M_ios_iostate_end = 1 << 16 };
  
    inline _Ios_Iostate 
    operator&(_Ios_Iostate __a, _Ios_Iostate __b)
--- 102,108 ----
    { return _Ios_Openmode(~static_cast<int>(__a)); }
  
  
!   enum _Ios_Iostate { _M_ios_iostate_end = 1L << 16 };
  
    inline _Ios_Iostate 
    operator&(_Ios_Iostate __a, _Ios_Iostate __b)
*************** namespace std {
*** 132,138 ****
    operator~(_Ios_Iostate __a)
    { return _Ios_Iostate(~static_cast<int>(__a)); }
  
!   enum _Ios_Seekdir { _M_ios_seekdir_end = 1 << 16 };
  
    // 27.4.2  Class ios_base
    class ios_base
--- 132,138 ----
    operator~(_Ios_Iostate __a)
    { return _Ios_Iostate(~static_cast<int>(__a)); }
  
!   enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
  
    // 27.4.2  Class ios_base
    class ios_base





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