stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r643078 - in /stdcxx/trunk: include/iomanip include/loc/_num_get.cc src/ios.cpp
Date Mon, 31 Mar 2008 17:35:03 GMT
Author: sebor
Date: Mon Mar 31 10:35:02 2008
New Revision: 643078

URL: http://svn.apache.org/viewvc?rev=643078&view=rev
Log:
2008-03-31  Martin Sebor  <sebor@roguewave.com>

	STDCXX-814
	* include/iomanip (__rw_setbase): Cast first argument of a shift
	expression to unsigned int to avoid benign arithmetic overflow
	and silence HP aCC 6 remark #4300: Overflow while computing
	constant in left shift operation.
	* include/loc/_num_get.cc (num_get::_C_get): Same.
	* src/ios.cpp (ios_base::flags): Same.

Modified:
    stdcxx/trunk/include/iomanip
    stdcxx/trunk/include/loc/_num_get.cc
    stdcxx/trunk/src/ios.cpp

Modified: stdcxx/trunk/include/iomanip
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/iomanip?rev=643078&r1=643077&r2=643078&view=diff
==============================================================================
--- stdcxx/trunk/include/iomanip (original)
+++ stdcxx/trunk/include/iomanip Mon Mar 31 10:35:02 2008
@@ -23,7 +23,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2005 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -87,7 +87,8 @@
 
         const unsigned __ifl =
               __strm.flags () & ~_STD::ios_base::basefield
-            & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
+            & ~(   _RWSTD_STATIC_CAST (unsigned, _RWSTD_IOS_BASEMASK)
+                << _RWSTD_IOS_BASEOFF)
             | __base << _RWSTD_IOS_BASEOFF;
 
         __strm.flags (_STD::ios_base::fmtflags (__ifl));

Modified: stdcxx/trunk/include/loc/_num_get.cc
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/loc/_num_get.cc?rev=643078&r1=643077&r2=643078&view=diff
==============================================================================
--- stdcxx/trunk/include/loc/_num_get.cc (original)
+++ stdcxx/trunk/include/loc/_num_get.cc Mon Mar 31 10:35:02 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 2001-2006 Rogue Wave Software.
+ * Copyright 2001-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -490,7 +490,8 @@
     // set the base determined above
     const unsigned __fl2 =
           __fl & ~_RWSTD_IOS_BASEFIELD
-        & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
+        & ~(   _RWSTD_STATIC_CAST (unsigned, _RWSTD_IOS_BASEMASK)
+            << _RWSTD_IOS_BASEOFF)
         | __base << _RWSTD_IOS_BASEOFF;
 
     // 22.2.2.1.2, p11: Stage 3

Modified: stdcxx/trunk/src/ios.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/ios.cpp?rev=643078&r1=643077&r2=643078&view=diff
==============================================================================
--- stdcxx/trunk/src/ios.cpp (original)
+++ stdcxx/trunk/src/ios.cpp Mon Mar 31 10:35:02 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -95,29 +95,28 @@
 
 ios_base::fmtflags ios_base::flags (fmtflags fl)
 {
+    const unsigned mask =
+        ~(unsigned (_RWSTD_IOS_BASEMASK) << _RWSTD_IOS_BASEOFF);
+
     unsigned ifl = unsigned (fl);
 
     switch (fl & basefield) {
         // if basefield is set, clear the base mask and set
         // the numeric base bits according to the basefield
     case oct:
-        ifl = ifl & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
-                  | 8U << _RWSTD_IOS_BASEOFF;
+        ifl = ifl &  mask | 8U << _RWSTD_IOS_BASEOFF;
         break;
 
     case dec:
-        ifl = ifl & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
-                  | 10U << _RWSTD_IOS_BASEOFF;
+        ifl = ifl & mask | 10U << _RWSTD_IOS_BASEOFF;
         break;
 
     case hex:
-        ifl = ifl & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
-                  | 16U << _RWSTD_IOS_BASEOFF;
+        ifl = ifl & mask | 16U << _RWSTD_IOS_BASEOFF;
         break;
 
     case _RWSTD_IOS_BIN:
-        ifl = ifl & ~(_RWSTD_IOS_BASEMASK << _RWSTD_IOS_BASEOFF)
-                  | 2U << _RWSTD_IOS_BASEOFF;
+        ifl = ifl & mask | 2U << _RWSTD_IOS_BASEOFF;
         break;
 
     case 0:



Mime
View raw message