stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r641549 - /stdcxx/trunk/src/locale_body.cpp
Date Wed, 26 Mar 2008 20:24:00 GMT
Author: sebor
Date: Wed Mar 26 13:23:58 2008
New Revision: 641549

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

	* src/locale_body.cpp (_C_manage): Used the C++ const_cast to cast
	away volatile in favor of the C-style variant introduced in a patch
	for STDCXX-792 (rev 640746) to avoid gcc -Wcast-qual warning: cast
	from type 'volatile int*' to type 'int*' casts away constness.

Modified:
    stdcxx/trunk/src/locale_body.cpp

Modified: stdcxx/trunk/src/locale_body.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/locale_body.cpp?rev=641549&r1=641548&r2=641549&view=diff
==============================================================================
--- stdcxx/trunk/src/locale_body.cpp (original)
+++ stdcxx/trunk/src/locale_body.cpp Wed Mar 26 13:23:58 2008
@@ -805,15 +805,20 @@
 
         if (!global) {
 
+            // volatile to prevent optimizers from turning
+            // the while statement below into an infinite loop
             static volatile int ginit /* = 0 */;
 
             // cast ginit to int& (STDCXX-792)
             // casting should be removed after fixing STDCXX-794
-            if (!ginit && 1 == _RWSTD_ATOMIC_PREINCREMENT ((int&)ginit, false))
{
+            if (!ginit && 1 == _RWSTD_ATOMIC_PREINCREMENT (
+                    _RWSTD_CONST_CAST (int&, ginit), false)) {
                 global  = _C_manage (0, "C");
                 ginit  += 1000;
             }
             else {
+                // ginit must be volatile to prevent optimizers
+                // from turning this into an infinite loop
                 while (ginit < 1000);
             }
         }



Mime
View raw message