Boost C++ Libraries: Ticket #11330: boost::chrono::duration default constructor doesn't initialize rep_ https://svn.boost.org/trac10/ticket/11330 <p> According to the documentation: </p> <pre class="wiki">constexpr duration(); Effects: Constructs an object of type duration from duration_values&lt;rep&gt;::zero(). </pre><p> The implementation is: </p> <pre class="wiki">#if defined BOOST_NO_CXX11_DEFAULTED_FUNCTIONS BOOST_FORCEINLINE BOOST_CONSTEXPR duration() : rep_(duration_values&lt;rep&gt;::zero()) { } #else BOOST_CONSTEXPR duration() BOOST_NOEXCEPT {}; #endif </pre><p> So in one side is does initialise to zero, not in the other side. This is a breaking change triggering tons of MSan issues in my application (and certainly bugs in real applications). Setting rep_ to zero() as it is done above fixes the issue for me. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11330 Trac 1.4.3 viboes Thu, 21 May 2015 20:42:50 GMT status changed https://svn.boost.org/trac10/ticket/11330#comment:1 https://svn.boost.org/trac10/ticket/11330#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Hi, </p> <p> you are right that there is an inconsistency I need to document. </p> <p> The correct behavior is, following the standard, to don't initialize it. I received a request to be able to initialize it a zero. </p> <p> I'm really sorry, but I would not initialize it in c++11. I could add a compiler flag to force the initialization. </p> <pre class="wiki">#if defined BOOST_NO_CXX11_DEFAULTED_FUNCTIONS || \ defined BOOST_CHRONO_DURATION_DEFAULTS_TO_ZERO BOOST_FORCEINLINE BOOST_CONSTEXPR duration() : rep_(duration_values&lt;rep&gt;::zero()) { } #else BOOST_CONSTEXPR duration() BOOST_NOEXCEPT {}; #endif </pre> Ticket florent.castelli@… Thu, 21 May 2015 21:07:00 GMT <link>https://svn.boost.org/trac10/ticket/11330#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11330#comment:2</guid> <description> <p> I guess that's fair as long as it is documented as a breaking change and the documentation doesn't claim it is initialized. </p> <p> I was thinking of possibly migrating the code to std::chrono so I'll have to make sure everything is properly initialized anyway. In the mean time, I guess having a local patch to initialize it to zero so I can migrate the rest of my code to 1.58.0 is fine. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 29 May 2015 17:56:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11330#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11330#comment:3</guid> <description> <p> So you agree for been forced to define BOOST_CHRONO_DURATION_DEFAULTS_TO_ZERO? </p> </description> <category>Ticket</category> </item> <item> <author>florent.castelli@…</author> <pubDate>Tue, 14 Jul 2015 15:01:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11330#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11330#comment:4</guid> <description> <p> Yes </p> </description> <category>Ticket</category> </item> <item> <author>florent.castelli@…</author> <pubDate>Tue, 14 Jul 2015 15:01:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11330#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11330#comment:4</guid> <description> <p> Yes </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 03 Aug 2015 20:55:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11330#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11330#comment:5</guid> <description> <p> I was on vacation. I will do it asap. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 05 Aug 2015 17:35:21 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11330#comment:6 https://svn.boost.org/trac10/ticket/11330#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/chrono/commit/6c7ff6678eea57e1e4e22c29ae9a7bfc023826ff"><span class="icon">​</span>https://github.com/boostorg/chrono/commit/6c7ff6678eea57e1e4e22c29ae9a7bfc023826ff</a> </p> Ticket viboes Sun, 25 Oct 2015 23:53:59 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11330#comment:7 https://svn.boost.org/trac10/ticket/11330#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket