Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-02-23 05:07:30

Joaquín Mª López Muñoz wrote:
>>> Would it be an idea to suppress these with some #pragma's if
>>> they've been investigated and found harmless?
>> It can be a good idea, but I need to make sure that #pragma
>> warning(push) and #pragma warning(pop) can be used here in such a
>> manner as to not suppress this otherwise useful warning in user
>> code. Would you volunteer to try some tests in your environment (I
>> don't have VC7.1 or 8.0) before commiting such a change?

How about the patch below then - turns off the warnings only for your code.
Note that the suppression of the std::equal warning will suppress the
warning for any further uses of that template instance as well (since a
template is instantiated only once).


$ cvs diff -u boost/multi_index
johnmaddock_at_[hidden]'s password:
cvs diff: Diffing boost/multi_index
Index: boost/multi_index/ordered_index.hpp
RCS file: /cvsroot/boost/boost/boost/multi_index/ordered_index.hpp,v
retrieving revision 1.14
diff -u -r1.14 ordered_index.hpp
--- boost/multi_index/ordered_index.hpp 19 May 2006 06:51:20 -0000 1.14
+++ boost/multi_index/ordered_index.hpp 23 Feb 2007 10:04:46 -0000
@@ -1092,7 +1092,15 @@
ordered_index<KeyFromValue1,Compare1,SuperMeta1,TagList1,Category1>& x,
ordered_index<KeyFromValue2,Compare2,SuperMeta2,TagList2,Category2>& y)

+#ifdef BOOST_MSVC
+// suppress std lib security warning:
+#pragma warning(push)
+#pragma warning(disable:4996)
   return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin());
+#ifdef BOOST_MSVC
+#pragma warning(pop)

cvs diff: Diffing boost/multi_index/detail
Index: boost/multi_index/detail/ord_index_node.hpp
RCS file: /cvsroot/boost/boost/boost/multi_index/detail/ord_index_node.hpp,v
retrieving revision 1.7
diff -u -r1.7 ord_index_node.hpp
--- boost/multi_index/detail/ord_index_node.hpp 19 May 2006
06:48:22 -00001.7
+++ boost/multi_index/detail/ord_index_node.hpp 23 Feb 2007 10:04:47 -0000
@@ -120,6 +120,14 @@

   struct parent_ref
+#ifdef BOOST_MSVC
+// This code casts pointers to an integer type that has been
+// computed to be large enough to hold the pointer, however
+// the metaprogramming logic isn't spotted by the VC++ code
+// analyser that issues a long list of warnings:
+#pragma warning(push)
+#pragma warning(disable:4312 4311)
     parent_ref(uintptr_type* r_):r(r_){}

     operator ordered_index_node_impl*()const
@@ -158,6 +166,9 @@
+#ifdef BOOST_MSVC
+#pragma warning(pop)

   ordered_index_node_impl*& left(){return left_;}
   ordered_index_node_impl* left()const{return left_;}

Boost list run by bdawes at, gregod at, cpdaniel at, john at