Boost C++ Libraries: Ticket #9503: Compile error C4996 with boost::uuids:uuid and vc2012 https://svn.boost.org/trac10/ticket/9503 <p> When compiling uuid under vc2012 with safe check enabled the C4996 warning is escalated to ERROR status. </p> <pre class="wiki">c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(965): error C4996: 'std::_Swap_ranges': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' 1&gt; c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(950) : see declaration of 'std::_Swap_ranges' 1&gt; c:\boost\boost_1_55_0\boost\uuid\uuid.hpp(151) : see reference to function template instantiation '_FwdIt2 std::swap_ranges&lt;boost::uuids::uuid::iterator,boost::uuids::uuid::iterator&gt;(_FwdIt1,_FwdIt1,_FwdIt2)' being compiled 1&gt; with 1&gt; [ 1&gt; _FwdIt2=boost::uuids::uuid::iterator, 1&gt; _FwdIt1=boost::uuids::uuid::iterator 1&gt; ] </pre><p> The pragma that already exists in boost_1_55_0\boost\uuid\uuid.hpp does not cater for this: </p> <pre class="wiki">#pragma warning(disable : 4996) </pre><p> I have attached a modified uuid which uses std::array as a sensible solution - this was actually commented in the original code. Now this enables safe iterators for compiler checks to be performed and removed any need for the #pragma pre-processor directives. There may be other changes needed elsewhere(i.e. &amp;*uuid.begin() in functions needing void*). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9503 Trac 1.4.3 Craig Hutchinson <craig@…> Tue, 17 Dec 2013 16:06:25 GMT attachment set https://svn.boost.org/trac10/ticket/9503 https://svn.boost.org/trac10/ticket/9503 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">uuid.hpp</span> </li> </ul> <p> Modified uuid.hpp to use std::array </p> Ticket Craig Hutchinson <craig@…> Tue, 17 Dec 2013 16:08:57 GMT <link>https://svn.boost.org/trac10/ticket/9503#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9503#comment:1</guid> <description> <p> I should add that I changed is_nil() to use find_if(). It is wrong and should return ... == end(); </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 22 Dec 2013 20:29:01 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/9503#comment:2 https://svn.boost.org/trac10/ticket/9503#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Andy Tompkins</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">uuid</span> </li> </ul> Ticket Steven Watanabe Fri, 04 Apr 2014 17:19:12 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9503#comment:3 https://svn.boost.org/trac10/ticket/9503#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Just use -D_SCL_SECURE_NO_WARNINGS. Using std::array will break compilation on C++03 compilers. This warning is spurious, difficult to work around, and impossible to suppress. </p> Ticket