Boost C++ Libraries: Ticket #4964: Annoying assert from runtime library when calling a function from boost::numeric::interval<double> https://svn.boost.org/trac10/ticket/4964 <p> The following code sequence creates an assert in _control87(): </p> <p> boost::numeric::interval&lt;double&gt; i(0.0, 0.0); boost::numeric::interval&lt;double&gt; i2 = 60.0 - i; </p> <p> The assert dialog states the following: </p> <hr /> <p> Microsoft Visual C++ Debug Library </p> <hr /> <p> Debug Assertion Failed! </p> <p> Program: ... File: amd64\ieee.c Line: 109 </p> <p> Expression: (mask&amp;~(_MCW_DN|_MCW_EM|_MCW_RC))==0 </p> <p> For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. </p> <p> (Press Retry to debug the application) </p> <hr /> <p> Abbrechen Wiederholen Ignorieren </p> <hr /> <p> This happens on Windows 7 64 Bit using Vc8, Vc9 or Vc10 and creating x64 debug binaries. 32 bit builds are not affected. </p> <p> The problem seems to be that _control87 doesn't accept _MCW_PC or _MCW_IC as mask bits in 64 bit mode. Removing those bits from the mask let the assert vanish. </p> <p> I simply modified set_rounding_mode() in "boost\numeric\interval\detail\msvc_rounding_control.hpp": </p> <blockquote> <p> static void set_rounding_mode(const rounding_mode mode) { </p> <blockquote> <p> _control87( </p> <blockquote> <p> hard2msvc(mode), </p> </blockquote> </blockquote> <p> #if defined(_M_AMD64) </p> <blockquote> <blockquote> <p> _MCW_EM | _MCW_RC </p> </blockquote> </blockquote> <p> #else </p> <blockquote> <blockquote> <p> _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC </p> </blockquote> </blockquote> <p> #endif </p> <blockquote> <blockquote> <p> ); </p> </blockquote> </blockquote> <p> } </p> </blockquote> <p> Microsoft says on MSDN (when you google for _control87): "On the x64 architecture, changing the floating point precision is not supported. If the precision control mask is used on that platform, an assertion and the invalid parameter handler is invoked, as described in Parameter Validation." </p> <p> The same seems to be true for _MCW_IC. </p> <p> You can verify the fact with a simply command line program like: </p> <blockquote> <p> #include &lt;float.h&gt; </p> </blockquote> <blockquote> <p> int _tmain(int argc, _TCHAR* argv[]) { </p> <blockquote> <p> unsigned int cur = _control87(0, 0); _control87(_MCW_EM | _PC_64 | _RC_UP | _IC_AFFINE, </p> <blockquote> <p> _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); </p> </blockquote> <p> _control87(cur, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); return 0; </p> </blockquote> <p> } </p> </blockquote> <p> You will get an assert in both calls to _control87 when you compile this in debug mode for the x64 platform. </p> <p> Kind regards, Torsten </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4964 Trac 1.4.3 prabhu.swain@… Mon, 13 Dec 2010 10:01:54 GMT cc set https://svn.boost.org/trac10/ticket/4964#comment:1 https://svn.boost.org/trac10/ticket/4964#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">prabhu.swain@…</span> added </li> </ul> Ticket anonymous Fri, 04 Feb 2011 18:20:48 GMT <link>https://svn.boost.org/trac10/ticket/4964#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4964#comment:2</guid> <description> <p> Thanks for your post, you saved my day... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>fkonvick</dc:creator> <pubDate>Mon, 08 Oct 2012 09:42:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4964#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4964#comment:3</guid> <description> <p> Is this getting any attention? I can reproduce the same here with MSVC 2012. </p> </description> <category>Ticket</category> </item> <item> <author>filip.konvicka@…</author> <pubDate>Thu, 11 Oct 2012 13:23:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4964#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4964#comment:4</guid> <description> <p> Is there any chance of integrating the fix provided above by Torsten to 1.52? I would definitely say the severity is not Cosmetic. </p> <p> I can generate the patchfile if needed. Otherwise I will need to keep applying the patch to all boost releases.... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>fkonvick</dc:creator> <pubDate>Thu, 23 Oct 2014 13:12:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4964#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4964#comment:5</guid> <description> <p> I have issued a pull-request on this. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>fkonvick</dc:creator> <pubDate>Mon, 01 Dec 2014 22:42:11 GMT</pubDate> <title>status, version, severity, milestone changed; resolution set https://svn.boost.org/trac10/ticket/4964#comment:6 https://svn.boost.org/trac10/ticket/4964#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.45.0</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Cosmetic</span> → <span class="trac-field-new">Problem</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.58.0</span> </li> </ul> <p> This is now fixed on master, commits 362724ba91c1ff36b94af425e889cd6cfb0bca78 and e172bd645b4263fbee20a85d4aedd2da44c4967c. Should be available in Boost 1.58. </p> Ticket