{"id":7281,"date":"2015-12-07T09:20:00","date_gmt":"2015-12-07T09:20:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/12\/07\/stl-fixes-in-vs-2015-update-1\/"},"modified":"2019-02-18T18:04:53","modified_gmt":"2019-02-18T18:04:53","slug":"stl-fixes-in-vs-2015-update-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/stl-fixes-in-vs-2015-update-1\/","title":{"rendered":"STL Fixes In VS 2015 Update 1"},"content":{"rendered":"<p><span style=\"font-family: Verdana;font-size: 12pt\">VS 2015 Update 1 is <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2015\/12\/01\/visual-studio-2015-update-1-is-available.aspx\"><span style=\"color: blue;text-decoration: underline\">now available<\/span><\/a>, and it contains numerous STL fixes.&nbsp; (This is the first time since 2010 SP1 that we&#8217;ve shipped STL fixes outside of a major version.&nbsp; Nothing was severely broken in 2015 RTM &#8211; we&#8217;re just trying to deliver fixes to you faster, and our internal processes are making this easier.)&nbsp; As usual, I&#8217;ve written up an exhaustive changelog, like <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2014\/06\/06\/c-14-stl-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1.aspx\"><span style=\"color: blue;text-decoration: underline\">Part 1<\/span><\/a> and <a href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2015\/07\/14\/stl-fixes-in-vs-2015-part-2.aspx\"><span style=\"color: blue;text-decoration: underline\">Part 2<\/span><\/a> for the fixes in 2015 RTM.&nbsp; Note that while Update 1 contains many compiler\/IDE\/etc. improvements (including partial support for Expression SFINAE), they aren&#8217;t mentioned here &#8211; I can&#8217;t personally keep track of everything! <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">First, Steve Wishnousky recently joined the VC Libraries team, and he got a couple of fixes into Update 1: <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* unordered_meow::max_bucket_count() was returning an incorrect value (VSO#144294\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1764567\"><span style=\"color: blue;text-decoration: underline\">Connect#1764567<\/span><\/a>).&nbsp; Now it&#8217;s correct. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* Our internal helper functions _Allocate() and _Deallocate() were unnecessarily templated, producing larger-than-necessary object files (VSO#130290).&nbsp; Now they&#8217;re de-templatized, which should shrink object files slightly. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Also, Hong Hong fixed a couple of bugs reported in &lt;future&gt; which were caused by its internal inclusion of &lt;ppltasks.h&gt;\/etc.: <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* &lt;future&gt; didn&#8217;t respect _HAS_EXCEPTIONS=0 (TFS#1127004\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1137364\"><span style=\"color: blue;text-decoration: underline\">Connect#1137364<\/span><\/a>).&nbsp; While this is currently undocumented, untested, and unsupported by Microsoft, we decided to fix this problem anyways. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* &lt;future&gt; was indirectly defining a non-Standard stdx::declval() (TFS#1194345\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1494998\"><span style=\"color: blue;text-decoration: underline\">Connect#1494998<\/span><\/a>).&nbsp; This internal helper has been renamed to Concurrency::details::declval().&nbsp; (For the time being, it&#8217;s by design that &lt;future&gt; drags in the non-_Ugly Concurrency namespace and the machinery within.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Next, I fixed several bugs: <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* Given enable_shared_from_this&lt;X&gt;, attempting to use shared_ptr&lt;volatile X&gt; would fail to compile (TFS#1178296).&nbsp; Now volatile works like const always has. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* allocator_traits incorrectly assumed that UserAlloc::construct()\/destroy() returned void (when they existed), triggering compiler errors for non-void return types (TFS#1184701).&nbsp; Now we properly accept (and ignore) non-void return types. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* In 2015 RTM&#8217;s tuple_size\/tuple_element, I tried to be helpful by static_asserting about non-tuple-ish things.&nbsp; Unfortunately, that prevents SFINAE, so it&#8217;s non-conformant (TFS#1192603, TFS#1205400\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1600812\"><span style=\"color: blue;text-decoration: underline\">Connect#1600812<\/span><\/a>).&nbsp; Now we&#8217;re following the Standard. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* The Standard requires rethrow_exception() to be marked [[noreturn]], but ours wasn&#8217;t, which could break code at compile time (VSO#125155\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1657472\"><span style=\"color: blue;text-decoration: underline\">Connect#1657472<\/span><\/a>).&nbsp; In addition to fixing this, I checked for any other missing occurrences (there weren&#8217;t any), and I changed every __declspec(noreturn) in the STL to be [[noreturn]] instead.&nbsp; (They&#8217;re synonymous, so this is simply an attempt to use Standard machinery when possible.&nbsp; Note that the CRT continues to use the __declspec.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* In 2015 RTM&#8217;s mem_fn(), I tried to be clever by handling a particularly obscure scenario with calling conventions.&nbsp; This had a barely-observable effect on the function&#8217;s signature, which users inevitably noticed (VSO#134162).&nbsp; I&#8217;ve removed the cleverness, so mem_fn() follows the Standard exactly. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* atomic&lt;FunctionPointer&gt; was accidentally using non-Standard behavior from C1XX, VC&#8217;s compiler front-end (TFS#1181758\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1393505\"><span style=\"color: blue;text-decoration: underline\">Connect#1393505<\/span><\/a>).&nbsp; (The issue was: When casting between void * and Object *, static_cast and reinterpret_cast are equivalent. However, when casting between void * and Function *, static_cast is forbidden while reinterpret_cast works, N4567 5.2.10 [expr.reinterpret.cast]\/8.)&nbsp; &lt;atomic&gt; now uses reinterpret_cast, following the Standard. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* In addition to &lt;atomic&gt;, I fixed the STL&#8217;s headers (and tests) to work with Clang\/C2 (&#8220;Clang with Microsoft CodeGen&#8221;), which will also benefit Clang\/LLVM.&nbsp; Our headers had very little accidental usage of non-Standard behavior to begin with, thanks to many years of stringent testing with EDG (the front-end used for IntelliSense), so only a few header changes were necessary.&nbsp; As part of this work, I reported many bugs in Clang\/C2 which were fixed before releasing, so you&#8217;ll never suffer from them.&nbsp; This even identified a few bugs (e.g. type traits, CRLFs in raw string literals) and opportunities for improvement in Clang itself, which will benefit Clang\/LLVM for Windows and non-Windows platforms.&nbsp; Special thanks to David Majnemer (unaffiliated with Microsoft) and the other Clang devs who implemented these bugfixes and improvements upstream. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Technical details: Clang 3.7 shipped with a couple of options, -fms-extensions and -fms-compatibility.&nbsp; -fms-extensions controls non-Standard features like __declspec(dllexport), which the STL requires to get its job done.&nbsp; -fms-compatibility controls &#8220;bug compatibility&#8221; (i.e. making Clang imitate C1XX bugs), but when David and I met at CppCon 2015, we realized that there are two kinds of bug compatibility: bugs that affect ABI (e.g. layout) and bugs that don&#8217;t affect ABI (e.g. accepts-invalid).&nbsp; So there have been changes committed to Clang&#8217;s post-3.7 trunk (and ported to the Clang\/C2 release).&nbsp; Now, ABI-relevant bug compatibility is always enabled when targeting Windows, as this is required to be link-compatible with C1XX\/C2 binaries.&nbsp; ABI-irrelevant bug compatibility is controlled by -fms-compatibility.&nbsp; Our STL&#8217;s headers (and tests) now work with -fno-ms\n-compatibility, the strictest level of conformance.&nbsp; (There&#8217;s one minor exception: &lt;future&gt; drags in &lt;ppltasks.h&gt; which was doing something non-conformant although fairly innocuous.&nbsp; The Standard doesn&#8217;t permit incomplete classes to be returned by value, even from &#8220;imaginary&#8221; functions that are declared but never defined.&nbsp; By the time I discovered this, it was too late to get a fix into Update 1, so Clang\/C2 was temporarily hacked before releasing in order to accept this specific thing.&nbsp; I&#8217;ve fixed &lt;ppltasks.h&gt; for Update 2, so the Clang\/C2 workaround can eventually be removed.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* While I was in the neighborhood, I also fixed the STL&#8217;s headers to work with \/Za, and added comprehensive test coverage.&nbsp; \/Za is C1XX&#8217;s option to enable extra conformance, but it also enables extra compiler bugs in rarely-used codepaths, so we discourage its use.&nbsp; (I stopped testing the STL with \/Za years ago when it broke perfectly valid uses of vector&lt;unique_ptr&lt;T&gt;&gt;.&nbsp; That was eventually fixed, but I didn&#8217;t resume testing until now.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Note that \/Za is still affected by a compiler bug that will prevent you from using it with the STL (in general).&nbsp; VSO#122298\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1331482\"><span style=\"color: blue;text-decoration: underline\">Connect#1331482<\/span><\/a> &#8220;__declspec(selectany) constexpr doesn&#8217;t work with \/Za&#8221; triggers linker errors when multiple translation units drag in &lt;limits&gt;, which was constexprized in 2015 RTM.&nbsp; The compiler has been fixed for Update 2.&nbsp; (I temporarily worked around it in the STL&#8217;s tests &#8211; we have only one with multiple TUs, hilariously enough.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* numeric_limits&lt;float\/double\/long double&gt;::infinity()\/quiet_NaN()\/signaling_NaN() are now constexpr, powered by GCC\/Clang&#8217;s compiler builtins that have been implemented in C1XX\/EDG.&nbsp; Note that signaling_NaN() specifically is affected by a C1XX bug (VSO#128935\/<a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/feedback\/details\/1686806\"><span style=\"color: blue;text-decoration: underline\">Connect#1686806<\/span><\/a>), causing the sNaN&#8217;s bits to be modified as they&#8217;re returned from a function, which the STL obviously can&#8217;t work around. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* &lt;exception&gt; was missing several occurrences of noexcept, which I&#8217;ve added. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* The performance of shared_ptr&#8217;s atomic operations (the weird free functions, not the normal refcount manipulations) has been improved by avoiding unnecessary copies. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* bitset&lt;0&gt;&#8217;s member functions misbehaved at runtime, as found by Clang\/libc++&#8217;s test suite (TFS#917456, TFS#917467).&nbsp; Now they behave correctly, although bitset&lt;0&gt; is still the most useless thing imaginable. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Finally, although I don&#8217;t usually list compiler fixes even when they affect the STL (e.g. &lt;type_traits&gt;), there&#8217;s one worth mentioning: <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">* Tanveer Gani fixed VSO#103444 &#8220;constexpr constructors are emitting dynamic initializers&#8221;.&nbsp; This affected the newly-constexprized STL, most importantly std::once_flag, which is now being statically initialized as required by the Standard.&nbsp; Note that this fix has some limitations that don&#8217;t affect the STL (e.g. having virtuals still prevents static initialization), and there&#8217;s a spurious warning that can be disabled &#8211; see Tanveer&#8217;s answer to <a href=\"http:\/\/stackoverflow.com\/questions\/34013930\/error-c4592-symbol-will-be-dynamically-initialized-vs2015-1-static-const-std\"><span style=\"color: blue;text-decoration: underline\">this StackOverflow question<\/span><\/a> for more information. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">That&#8217;s the end of the STL&#8217;s Update 1 changelog.&nbsp; Steve Wishnousky (<a href=\"https:\/\/twitter.com\/SteveWishnousky\"><span style=\"color: blue;text-decoration: underline\">@SteveWishnousky<\/span><\/a>), our other new hire Billy O&#8217;Neal (<a href=\"https:\/\/twitter.com\/malwareminigun\"><span style=\"color: blue;text-decoration: underline\">@MalwareMinigun<\/span><\/a>), and I are working on many more changes for Update 2 &#8211; we&#8217;ve already checked in dozens of fixes and 9 features!&nbsp; (This will be the first time since 2008 SP1 that we&#8217;ve shipped STL features outside of a major version.) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Stephan T. Lavavej (<a href=\"https:\/\/twitter.com\/stephantlavavej\"><span style=\"color: blue;text-decoration: underline\">@StephanTLavavej<\/span><\/a>) <\/span><\/p>\n<p><span style=\"font-family: Verdana;font-size: 12pt\">Senior Developer &#8211; Visual C++ Libraries <\/span><\/p>\n<p><a href=\"mailto:stl@microsoft.com\"><span style=\"color: blue;font-family: Verdana;font-size: 12pt;text-decoration: underline\">stl@microsoft.com<\/span><\/a><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>VS 2015 Update 1 is now available, and it contains numerous STL fixes.&nbsp; (This is the first time since 2010 SP1 that we&#8217;ve shipped STL fixes outside of a major version.&nbsp; Nothing was severely broken in 2015 RTM &#8211; we&#8217;re just trying to deliver fixes to you faster, and our internal processes are making this [&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-7281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>VS 2015 Update 1 is now available, and it contains numerous STL fixes.&nbsp; (This is the first time since 2010 SP1 that we&#8217;ve shipped STL fixes outside of a major version.&nbsp; Nothing was severely broken in 2015 RTM &#8211; we&#8217;re just trying to deliver fixes to you faster, and our internal processes are making this [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/7281","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=7281"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/7281\/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=7281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=7281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=7281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}