Boost C++ Libraries: Ticket #11519: Strange value of ptime variable https://svn.boost.org/trac10/ticket/11519 <p> The bug is produced by this example program: </p> <pre class="wiki">int main() { int n = ((20 * 2700 - 4000.0) / 20 / 300.0 + 0.5); boost::posix_time::ptime from; boost::posix_time::ptime beg = boost::posix_time::time_from_string("2015-07-29 11:40:00"); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5); beg = beg + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5) + boost::posix_time::minutes(5); for(int i = 7; i &lt; n; i++) { from = beg + boost::posix_time::minutes(5 * i); if(from!=beg+ boost::posix_time::minutes(5 * i)) std::cout &lt;&lt; "ERROR IN TIME: " &lt;&lt; boost::posix_time::to_iso_extended_string(from) &lt;&lt; std::endl &lt;&lt; boost::posix_time::to_iso_extended_string(beg+ boost::posix_time::minutes(5 * i)) &lt;&lt; std::endl; } return 0; } </pre><p> The result of this code is that it reaches the output (although it shouldn't) and outputs a strange value for <em>from</em>. I compiled this sample file with g++ 4.6.3 on Ubuntu 12.04 with the compiler flags <em>-O3</em> and <em>-frounding-math</em>. Although <em>-frounding-math</em> is necessary to produce this bug for this small example, in a much larger program the bug is still there without this flag. </p> <p> While debugging this code it seems for me that in </p> <pre class="wiki">from = beg + boost::posix_time::minutes(5 * i); </pre><p> the minutes are never initialized (but debugging with optimization is quite difficult). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11519 Trac 1.4.3 a0607892@… Thu, 06 Aug 2015 15:11:24 GMT <link>https://svn.boost.org/trac10/ticket/11519#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11519#comment:1</guid> <description> <p> With a newer version of g++ (4.7 as well as 5.1) and also with icpc (version 15) the bug cannot be reproduced. The program is then also Valgrind clean. Therefore, in my opinion, it seems to be a bug in the compiler. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>James E. King, III</dc:creator> <pubDate>Sat, 06 Jan 2018 15:35:15 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/11519#comment:2 https://svn.boost.org/trac10/ticket/11519#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">az_sw_dude</span> to <span class="trac-author">James E. King, III</span> </li> </ul> Ticket James E. King, III Sat, 06 Jan 2018 15:35:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11519#comment:3 https://svn.boost.org/trac10/ticket/11519#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">invalid</span> </li> </ul> <p> Given this is a compiler bug in an old compiler, I am resolving it as invalid. </p> Ticket