{"id":10035,"date":"2016-08-12T11:48:29","date_gmt":"2016-08-12T18:48:29","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=10035"},"modified":"2019-02-18T18:04:44","modified_gmt":"2019-02-18T18:04:44","slug":"stl-fixes-in-vs-2015-update-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/stl-fixes-in-vs-2015-update-3\/","title":{"rendered":"STL Fixes In VS 2015 Update 3"},"content":{"rendered":"<p><span style=\"font-family:Verdana;font-size:12pt\">VS 2015 Update 3 <a href=\"https:\/\/www.visualstudio.com\/news\/releasenotes\/vs2015-update3-vs\">was released<\/a> over a month ago.\u00a0 While its release notes mentioned some STL fixes, here&#8217;s a comprehensive list.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">(Previous changelogs: <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2014\/06\/06\/c14-stl-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1\/\">RTM Part 1<\/a>, <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/07\/14\/stl-fixes-in-vs-2015-part-2\/\">RTM Part 2<\/a>, <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/stl-fixes-in-vs-2015-update-1\/\">Update 1<\/a>, <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2016\/01\/22\/vs-2015-update-2s-stl-is-c17-so-far-feature-complete\/\">Update 2 features<\/a>, and <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2016\/04\/14\/stl-fixes-in-vs-2015-update-2\/\">Update 2 fixes<\/a>.)<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\"><strong>STL Features<\/strong><\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">\/std:c++latest enables the following new features: <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2015\/p0025r1.html\">P0025R1<\/a> &#8220;clamp()&#8221;, <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0185r1.html\">P0185R1<\/a> &#8220;is_swappable, is_nothrow_swappable&#8221;, and <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0272r1.html\">P0272R1<\/a> &#8220;Non-const basic_string::data()&#8221;.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">\/std:c++latest also controls the removal of the following old features: <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n4190.htm\">N4190<\/a> &#8220;Removing auto_ptr, random_shuffle(), And Old &lt;functional&gt; Stuff&#8221;, <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2015\/p0004r1.html\">P0004R1<\/a> &#8220;Removing Deprecated Iostreams Aliases&#8221;, <a href=\"http:\/\/cplusplus.github.io\/LWG\/lwg-defects.html\">LWG 2385<\/a> &#8220;function::assign allocator argument doesn&#8217;t make sense&#8221;, and various non-Standard features (the std::tr1 namespace, some TR1-only machinery, and the std::identity struct).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">The compiler options \/std:c++14 and \/std:c++latest are <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/standards-version-switches-in-the-compiler\/\">newly available<\/a> in Update 3.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">\/std:c++14 (which is the default) defines _MSVC_LANG to 201402 and says, &#8220;enable C++14 features as they become available, and enable the set of C++17 features that shipped in Update 2&#8221;. (This is intentionally different from Clang and GCC&#8217;s -std=c++14 mode.)<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">\/std:c++latest defines _MSVC_LANG &gt; 201402 (the exact value is subject to change) and says, &#8220;enable all features as they become available, including feature removals; I love conforming to the latest Working Paper and I am willing to accept arbitrary source breaking changes&#8221;.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Because our STL implementation supports three-and-a-half compilers (C1XX, Clang, EDG-imitating-C1XX, and EDG-imitating-Clang), we have a separate macro to control the STL&#8217;s mode.\u00a0 We inspect _MSVC_LANG if it&#8217;s defined, otherwise we inspect __cplusplus.\u00a0 (C1XX will not update __cplusplus&#8217;s value until it has implemented all C++11 features.)\u00a0 Then the STL defines _HAS_CXX17 to 0 or 1, and this is used to control the behavior of our headers.\u00a0 We will support overriding this macro, but only in one direction.\u00a0 \/std:c++latest \/D_HAS_CXX17=0 is an acceptable request for new compiler behavior, but old STL behavior.\u00a0 However, \/std:c++14 \/D_HAS_CXX17=1 is unacceptable (requesting old compiler behavior, but new STL behavior) &#8211; we aren&#8217;t attempting to block this and it&#8217;ll work for the time being, but it can and probably will stop working at some point in the future (whenever a new STL feature needs to take a dependency on a new compiler feature).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">In general, LWG issue resolutions will be implemented unconditionally, and will not be controlled by _HAS_CXX17.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Finally, while we don&#8217;t support fine-grained control of C++17 STL features, we have separate macros for the feature removals.\u00a0 They are _HAS_AUTO_PTR_ETC, _HAS_OLD_IOSTREAMS_MEMBERS, _HAS_FUNCTION_ASSIGN, _HAS_TR1_NAMESPACE, and _HAS_IDENTITY_STRUCT.\u00a0 They&#8217;re defined to 0 or 1 depending on the value of _HAS_CXX17, but they can be overridden (and we support all combinations).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\"><strong>LWG Issues<\/strong><\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">We implemented C++14&#8217;s <a href=\"http:\/\/cplusplus.github.io\/LWG\/lwg-defects.html\">LWG 2064<\/a> &#8220;More noexcept issues in basic_string&#8221;.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">We also implemented C++17&#8217;s <a href=\"http:\/\/cplusplus.github.io\/LWG\/lwg-defects.html\">LWG 2296<\/a> &#8220;std::addressof should be constexpr&#8221;, <a href=\"http:\/\/cplusplus.github.io\/LWG\/lwg-defects.html\">LWG 2596<\/a> &#8220;vector::data() should use addressof&#8221;, and <a href=\"http:\/\/cplusplus.github.io\/LWG\/lwg-defects.html\">LWG 2688<\/a> &#8220;clamp misses preconditions and has extraneous condition on result&#8221;.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\"><strong>STL Fixes<\/strong><\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">In Update 2, we removed metaprogramming in an internal _Destroy_range() helper.\u00a0 This metaprogramming was unnecessary in release mode, but its removal significantly impacted debug mode performance (VSO#213185, VSO#218398\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2661660\">Connect#2661660<\/a>, VSO#219797\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2683478\">Connect#2683478<\/a>).\u00a0 In Update 3, we&#8217;ve fixed this regression by restoring and improving the metaprogramming.\u00a0 Unlike the pre-Update 2 metaprogramming, the new metaprogramming calls a user-defined allocator&#8217;s destroy() if it is present. User-defined allocators may need to use the C++11 minimal allocator interface in order to restore pre-Update 2 debug performance, typically by removing construct() and destroy() member functions.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance by generalizing a metaprogramming optimization to apply to user-defined allocators, not just std::allocator (VSO#189231).\u00a0 This optimization is activated when construct() and destroy() aren&#8217;t provided by the user-defined allocator.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed silent bad codegen in atomic&lt;int64_t&gt;\/atomic&lt;uint64_t&gt; on x86 (VSO#212461).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">The STL now avoids using <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2008\/n2660.htm\">thread-safe &#8220;magic statics&#8221;<\/a> except when absolutely necessary, improving codegen.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">tuple&#8217;s perfect forwarding constructor now avoids out-competing the copy constructor, fixing compiler errors in certain scenarios (VSO#215996\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2632801\">Connect#2632801<\/a>, VSO#216014\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2633029\">Connect#2633029<\/a>).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of std::equal and std::lexicographical_compare by dispatching to memcmp and memchr more aggressively, resulting in large performance improvements in some scenarios; e.g. equal(char*,char*,char*, char*) on 64-bit platforms (VSO#180464).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of debug builds significantly by reducing the number of bookkeeping function calls in our iterator debugging machinery.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of string::push_back another 40% vs. Update 2 in release builds, with more substantial improvements in debug builds.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of debug builds across all standard algorithms by eliminating several kinds of empty template metaprogramming support calls (e.g. _Iter_cat).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance across all algorithms that take function objects by reducing the number of function object copies (VSO#91245).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Applied improved diagnostics for _SCL_INSECURE_DEPRECATE messages to the remaining algorithms (in Update 2 only a small number of algorithms were hooked into the new deprecation mechanism). This also improves the debugging experience when debugging into the standard algorithms, as there is no longer any _ITERATOR_DEBUG_LEVEL preprocessor interaction declaring multiple copies of standard algorithms (VSO#180466).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed an inability to compile some functions like mismatch(iter, iter, T[]) due to an interaction between C++14&#8217;s dual-range algorithms and our slightly non-standard _ITERATOR_DEBUG_ARRAY_OVERLOADS (VSO#211972).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of std::mismatch under _ITERATOR_DEBUG_LEVEL 1 and 2 by range checking the second range where possible ahead of iteration.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed violations of the off-by-default warning C4242 in the STL (VSO#194854).\u00a0 Note that we fix off-by-default warnings rarely and on a case-by-case basis.\u00a0 Our policy is to remain \/W4 \/analyze clean, but we do not attempt to be \/Wall clean.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed a possible integer overflow bug in std::pop_heap (VSO#204655).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed a potential hang under \/clr:pure due to CLR-inserted LoadLibrary calls while holding the locale lock.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed the return value of atomic&lt;UDT&gt;::operator=() (VSO#197633\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2430244\">Connect#2430244<\/a>).\u00a0 Note that atomic&lt;integral&gt; and atomic&lt;T *&gt; were unaffected.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Improved performance of exception_ptr by using make_shared() internally.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Reduced stack space consumption of regex matching, avoiding stack overflows in more cases (VSO#208146).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed subtract_with_carry_engine::seed() to take result_type instead of unsigned long (VSO#214595\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/2610325\">Connect#2610325<\/a>).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Fixed the behavior of subtract_with_carry_engine when m == numeric_limits&lt;result_type&gt;::digits (VSO#219985).<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">We eliminated more unintentional usage of non-Standard compiler extensions in STL headers, improving conformance and making Clang happier (VSO#192363).\u00a0 Note that the iostreams headers contained three in-class specializations of _Getvals(), which is a non-Standard technique.\u00a0 Due to binary compatibility concerns, this remains unchanged in Update 3, but has been fixed for the next major version of the STL.\u00a0 (Clang accepts this without emitting a warning because STL headers are system headers.)<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">In RTM through Update 2, the STL contained an undocumented &#8220;escape hatch&#8221; to disable constexpr usage, which involved _CONST_FUN and _CONST_DATA macros appearing throughout the STL&#8217;s headers.\u00a0 This turned out to be unnecessary, so in Update 3 we&#8217;ve eliminated these macros.\u00a0 Now the STL&#8217;s headers mention &#8220;constexpr&#8221; unconditionally.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">std::is_assignable is now powered by a compiler hook for Clang (previously implemented for C1XX), simplifying the STL&#8217;s headers and potentially improving compiler throughput.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">std::addressof() is now powered by a compiler hook for C1XX and Clang, allowing it to be constexpr and improving compiler throughput.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">STL containers and iterators now support &#8220;fancy pointers&#8221;.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Function templates in locale code now defend themselves against overloaded comma operators.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">The STL now correctly handles POCS allocators (propagate_on_container_swap).\u00a0 Note that POCCA\/POCMA (propagate_on_container_copy_assignment\/propagate_on_container_move_assignment) are being severely mishandled, up to and including silent bad codegen.\u00a0 They have been fixed for the next release of the STL.<\/span>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Billy Robert O&#8217;Neal III &#8211; <a href=\"https:\/\/twitter.com\/malwareminigun\">@MalwareMinigun<\/a><\/span>\n\t<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">SDE II &#8211; Visual C++ Libraries<\/span>\n\t<\/p>\n<p><a href=\"mailto:bion@microsoft.com\"><span style=\"font-family:Verdana;font-size:12pt\">bion@microsoft.com<\/span><\/a>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Casey Carter &#8211; <a href=\"https:\/\/twitter.com\/codercasey\">@CoderCasey<\/a><\/span>\n\t<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">SDE II &#8211; Visual C++ Libraries<\/span>\n\t<\/p>\n<p><a href=\"mailto:cacarter@microsoft.com\"><span style=\"font-family:Verdana;font-size:12pt\">cacarter@microsoft.com<\/span><\/a>\n\t<\/p>\n<p>\n\u00a0<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Stephan T. Lavavej &#8211; <a href=\"https:\/\/twitter.com\/stephantlavavej\">@StephanTLavavej<\/a><\/span>\n\t<\/p>\n<p><span style=\"font-family:Verdana;font-size:12pt\">Senior Developer &#8211; Visual C++ Libraries<\/span>\n\t<\/p>\n<p><a href=\"mailto:stl@microsoft.com\"><span style=\"font-family:Verdana;font-size:12pt\">stl@microsoft.com<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>VS 2015 Update 3 was released over a month ago.\u00a0 While its release notes mentioned some STL fixes, here&#8217;s a comprehensive list. \u00a0 (Previous changelogs: RTM Part 1, RTM Part 2, Update 1, Update 2 features, and Update 2 fixes.) \u00a0 STL Features \u00a0 \/std:c++latest enables the following new features: P0025R1 &#8220;clamp()&#8221;, P0185R1 &#8220;is_swappable, is_nothrow_swappable&#8221;, [&hellip;]<\/p>\n","protected":false},"author":266,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10035","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>VS 2015 Update 3 was released over a month ago.\u00a0 While its release notes mentioned some STL fixes, here&#8217;s a comprehensive list. \u00a0 (Previous changelogs: RTM Part 1, RTM Part 2, Update 1, Update 2 features, and Update 2 fixes.) \u00a0 STL Features \u00a0 \/std:c++latest enables the following new features: P0025R1 &#8220;clamp()&#8221;, P0185R1 &#8220;is_swappable, is_nothrow_swappable&#8221;, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/10035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/266"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=10035"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/10035\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=10035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=10035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=10035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}