Boost C++ Libraries: Ticket #7111: Switch case's default missing in date_time https://svn.boost.org/trac10/ticket/7111 <p> In file boost/date_time/date_formatting.hpp in following code block, <strong>default case</strong> of switch condition is missing.Switch case should not be used without default case ideally.In case of default, code should break from the loop. </p> <pre class="wiki">static ostream_type&amp; format_month(const month_type&amp; month, ostream_type &amp;os) { switch (format_type::month_format()) { case month_as_short_string: { os &lt;&lt; month.as_short_string(); break; } case month_as_long_string: { os &lt;&lt; month.as_long_string(); break; } case month_as_integer: { os &lt;&lt; std::setw(2) &lt;&lt; std::setfill(os.widen('0')) &lt;&lt; month.as_number(); break; } } return os; } // format_month }; </pre><p> Attached patch is the fix for it. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7111 Trac 1.4.3 Gaurav Gupta <g.gupta@…> Tue, 10 Jul 2012 13:02:21 GMT attachment set https://svn.boost.org/trac10/ticket/7111 https://svn.boost.org/trac10/ticket/7111 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">date_formatting.hpp_patch</span> </li> </ul> <p> Fix for the reported Bug. </p> Ticket Marshall Clow Tue, 10 Jul 2012 14:20:48 GMT <link>https://svn.boost.org/trac10/ticket/7111#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7111#comment:1</guid> <description> <p> I'm sorry, but I don't see the point of this change. </p> <p> The code here is checking for all the possible values of the month_format_spec enum; there are no other (legal) values. </p> <p> Also, your patch does not change the behavior of the code; if an invalid value was returned the by <code>month_format()</code>, the current code would do nothing, and your patch would change it so that it would ... do nothing. </p> <p> Please tell me what you are trying to accomplish here. </p> <p> P.S. I am completely missing what you mean by: </p> <blockquote class="citation"> <p> <em>In case of default, code should break from the loop.</em> </p> </blockquote> <p> since I don't see a loop here. </p> </description> <category>Ticket</category> </item> <item> <author>Gaurav Gupta <g.gupta@…></author> <pubDate>Wed, 11 Jul 2012 09:13:11 GMT</pubDate> <title>severity changed https://svn.boost.org/trac10/ticket/7111#comment:2 https://svn.boost.org/trac10/ticket/7111#comment:2 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> <p> I just want to <strong>highlight the coding practices</strong>. Its a cosmetic bug. In future if somebody add more cases, it will be easier for the user as code will be more readable and behavior of switch will be visible. Its obvious that it is still not doing anything, but the readability is more and it is according to coding guidelines. </p> Ticket viboes Wed, 15 Aug 2012 13:53:30 GMT cc, status, type changed; resolution set https://svn.boost.org/trac10/ticket/7111#comment:3 https://svn.boost.org/trac10/ticket/7111#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <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> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> </ul> <p> There are too much work to do to clean up Boost.<a class="missing wiki">DateTime</a>. Re-open if some tool is warning a bad usage. </p> Ticket Gaurav Gupta <g.gupta@…> Tue, 25 Sep 2012 07:47:37 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/7111#comment:4 https://svn.boost.org/trac10/ticket/7111#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> If our application is using "Werror" flag, then if default case is not mentioned ,it is reported as an error. </p> Ticket Marshall Clow Tue, 25 Sep 2012 19:06:32 GMT <link>https://svn.boost.org/trac10/ticket/7111#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7111#comment:5</guid> <description> <p> Ok; I added a default case. But you should bug the gcc folks, since it's a bogus warning. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Tue, 25 Sep 2012 19:08:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7111#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7111#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80703" title="Added default case label to silence bogus warning; Refs #7111">[80703]</a>) Added default case label to silence bogus warning; Refs <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> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Tue, 25 Sep 2012 19:11:14 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/7111#comment:7 https://svn.boost.org/trac10/ticket/7111#comment:7 <ul> <li><strong>owner</strong> changed from <span class="trac-author">az_sw_dude</span> to <span class="trac-author">Marshall Clow</span> </li> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> Ticket Gaurav Gupta <g.gupta@…> Wed, 26 Sep 2012 03:09:14 GMT <link>https://svn.boost.org/trac10/ticket/7111#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7111#comment:8</guid> <description> <p> Thanks Marshall, Please commit similar warning errors in Ticket# 7112 &amp; 7113. </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/7111#comment:9 https://svn.boost.org/trac10/ticket/7111#comment:9 <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 Marshall Clow Mon, 07 Jan 2013 19:39:36 GMT <link>https://svn.boost.org/trac10/ticket/7111#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7111#comment:10</guid> <description> <p> BTW, clang now warns on this code. </p> <pre class="wiki">Warning: default label in switch which covers all enumeration values [ -Wcovered-switch-default ] </pre> </description> <category>Ticket</category> </item> </channel> </rss>