Boost C++ Libraries: Ticket #9075: Devision by zero in boost/date_time/int_adapter.hpp https://svn.boost.org/trac10/ticket/9075 <p> line 347 </p> <div class="wiki-code"><div class="code"><pre><span class="mi">339</span> <span class="cm">/*! Provided for cases when automatic conversion from </span> <span class="cm">340 * &#39;int&#39; to &#39;int_adapter&#39; causes incorrect results. */</span> <span class="mi">341</span> <span class="n">int_adapter</span> <span class="k">operator</span><span class="o">/</span><span class="p">(</span><span class="k">const</span> <span class="kt">int</span> <span class="n">rhs</span><span class="p">)</span> <span class="k">const</span> <span class="mi">342</span> <span class="p">{</span> <span class="mi">343</span> <span class="k">if</span><span class="p">(</span><span class="n">is_special</span><span class="p">()</span> <span class="o">&amp;&amp;</span> <span class="n">rhs</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="mi">344</span> <span class="p">{</span> <span class="mi">345</span> <span class="k">return</span> <span class="n">mult_div_specials</span><span class="p">(</span><span class="n">rhs</span><span class="p">);</span> <span class="mi">346</span> <span class="p">}</span> <span class="mi">347</span> <span class="k">return</span> <span class="n">int_adapter</span><span class="o">&lt;</span><span class="n">int_type</span><span class="o">&gt;</span><span class="p">(</span><span class="n">value_</span> <span class="o">/</span> <span class="n">rhs</span><span class="p">);</span> <span class="mi">348</span> <span class="p">}</span> </pre></div></div><p> rhs is not checked if is_special() returns false. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9075 Trac 1.4.3 Marshall Clow Tue, 15 Oct 2013 18:42:48 GMT <link>https://svn.boost.org/trac10/ticket/9075#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9075#comment:1</guid> <description> <p> Note that just above this (on lines 358-362) there is: </p> <pre class="wiki"> if(rhs != 0) { return mult_div_specials(rhs); } else { // let divide by zero blow itself up return int_adapter&lt;int_type&gt;(value_ % rhs.value_); </pre><p> so I think that this is deliberate. </p> <p> I don't know what *should* happen here. </p> </description> <category>Ticket</category> </item> </channel> </rss>