Boost C++ Libraries: Ticket #5550: Missing initializer warning in date_time/date_facet.hpp https://svn.boost.org/trac10/ticket/5550 <p> include/boost/date_time/date_facet.hpp is causing a compiler warning </p> <p> Compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) </p> <p> Compiler Options: g++4 -shared -fpic -g -Wall -Woverloaded-virtual -Werror -Wl,--warn-shared-textrel -Wl,--fatal-warnings </p> <pre class="wiki"> cc1plus: warnings being treated as errors boost_1_46_1/include/boost/date_time/date_facet.hpp: In member function ‘OutItrT boost::date_time::date_facet&lt;date_type, CharT, OutItrT&gt;::put(OutItrT, std::ios_base&amp;, CharT, const typename date_type::month_type&amp;) const [with date_type = boost::gregorian::date, CharT = char, OutItrT = std::ostreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt;]’: boost_1_46_1/include/boost/date_time/gregorian/gregorian_io.hpp:243: instantiated from ‘std::basic_ostream&lt;_CharT, _Traits&gt;&amp; boost::gregorian::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, const boost::gregorian::greg_month&amp;) [with CharT = char, TraitsT = std::char_traits&lt;char&gt;]’ &lt;source&gt;.cpp:##: instantiated from here boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_sec’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_min’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_hour’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_mday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_mon’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_year’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_wday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_yday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_isdst’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_gmtoff’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_zone’ </pre><p> std::tm dtm = {}; should be changed to something like std::tm dtm = std::tm(); </p> <p> This same issue was addressed and fixed in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3563" title="#3563: Patches: Warnings using g++ 4.4.0 on date_time/posix_time/conversion.hpp (closed: fixed)">#3563</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5550 Trac 1.4.3 Derek McGowan <derek@…> Wed, 18 May 2011 19:20:29 GMT component changed; owner set https://svn.boost.org/trac10/ticket/5550#comment:1 https://svn.boost.org/trac10/ticket/5550#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">az_sw_dude</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">date_time</span> </li> </ul> <p> Setting component to date_time </p> Ticket Manish Mulimani <manish.mulimani@…> Mon, 30 May 2011 09:55:18 GMT <link>https://svn.boost.org/trac10/ticket/5550#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5550#comment:2</guid> <description> <p> Can I work on this bug? </p> </description> <category>Ticket</category> </item> <item> <author>Manish Mulimani <manish.mulimani@…></author> <pubDate>Fri, 10 Jun 2011 11:37:57 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5550 https://svn.boost.org/trac10/ticket/5550 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patch_for_ticket#5550.diff</span> </li> </ul> <p> Patch for the bug. </p> Ticket Manish Mulimani <manish.mulimani@…> Fri, 01 Jul 2011 10:52:42 GMT cc set https://svn.boost.org/trac10/ticket/5550#comment:3 https://svn.boost.org/trac10/ticket/5550#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">manish.mulimani@…</span> added </li> </ul> Ticket Derek McGowan <derek@…> Fri, 28 Oct 2011 22:43:30 GMT cc, severity changed https://svn.boost.org/trac10/ticket/5550#comment:4 https://svn.boost.org/trac10/ticket/5550#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">derek@…</span> added </li> <li><strong>severity</strong> <span class="trac-field-old">Cosmetic</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> This is breaking our compilation, so I am upgrading it from cosmetic to a problem. Please submit patch. </p> Ticket Marshall Clow Wed, 26 Sep 2012 16:58:00 GMT <link>https://svn.boost.org/trac10/ticket/5550#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5550#comment:5</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80710" title="Use memset instead of default constructor (std::tm) for deficient ...">[80710]</a>) Use memset instead of default constructor (std::tm) for deficient compilers; Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Sun, 30 Sep 2012 23:25:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5550#comment:6 https://svn.boost.org/trac10/ticket/5550#comment:6 <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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80797" title="Merge bug fixes to release; Fixes #5550 Fixes #6136 Fixes #6513 Fixes ...">[80797]</a>) Merge bug fixes to release; Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6513" title="#6513: Bugs: assignment vs comparison in unit test (closed: fixed)">#6513</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7111" title="#7111: Feature Requests: Switch case's default missing in date_time (closed: fixed)">#7111</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7112" title="#7112: Feature Requests: Switch case default missing in date_time (closed: fixed)">#7112</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7113" title="#7113: Feature Requests: In date_time default case of switch is missing. (closed: fixed)">#7113</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7342" title="#7342: Bugs: Warning in format_date_parser.hpp (closed: fixed)">#7342</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7426" title="#7426: Patches: Warning fixes in datetime (closed: fixed)">#7426</a> </p> Ticket Johan Lundberg <lundberj@…> Wed, 19 Jun 2013 14:22:27 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/5550#comment:7 https://svn.boost.org/trac10/ticket/5550#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.46.1</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> This problem is there at two more places in another file (boost 1.54 beta1), giving the same errors/warnings as above. </p> <p> /date_time/strings_from_facet.hpp:53:20: warning: missing initializer for member ‘tm::tm_gmtoff’ [-Wmissing-field-initializers] <em>(and ten more like it)</em> </p> <p> /date_time/strings_from_facet.hpp:106:20: warning: missing initializer for member ‘tm::tm_zone’ [-Wmissing-field-initializers] <em>(and ten more like it)</em> </p> <p> Now, changeset <a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/80797"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/80797</a> suggest the change from </p> <p> tm tm_value = {}; </p> <p> to </p> <p> std::tm dtm; std::memset(&amp;dtm, 0, sizeof(dtm)); </p> <p> I've made this change (at two places) and that silences all related warnings. Using the more obvious tm_value = {0,0,0,0,0,0,0,0,0} is not a good idea since some implementations add their own values at the end of the struct. </p> <p> <strong>How to reproduce:</strong> </p> <p> #include "date_time/posix_time/posix_time.hpp" int main(){} </p> <p> <em>compile with gcc4.7.2, default options. </em></p> Ticket Marshall Clow Wed, 19 Jun 2013 15:36:33 GMT <link>https://svn.boost.org/trac10/ticket/5550#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5550#comment:8</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84835" title="Fixed more compiler warnings; Refs #5550">[84835]</a>) Fixed more compiler warnings; Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Fri, 21 Jun 2013 15:04:14 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5550#comment:9 https://svn.boost.org/trac10/ticket/5550#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84860" title="Merge bug fixes to release. Fixes #6136. Fixes #5550">[84860]</a>) Merge bug fixes to release. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> </p> Ticket