Boost C++ Libraries: Ticket #7068: Compiler warnings in date_time https://svn.boost.org/trac10/ticket/7068 <p> In reference to: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/7045"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/7045</a> </p> <p> The following warnings are issued for GCC 4.6 and 4.7 both MinGW and Linux GCC with "-wall" for boost 1.50: </p> <pre class="wiki">C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp||In function 'tm boost::gregorian::to_tm(const boost::gregorian::date&amp;)':| C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp|33|warning: enumeration value 'min_date_time' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp|33|warning: enumeration value 'max_date_time' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp|33|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp|33|warning: enumeration value 'NumSpecialValues' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp||In instantiation of 'static boost::date_time::int_adapter&lt;int_type_&gt; boost::date_time::int_adapter&lt;int_type_&gt;::from_special(boost::date_time::special_values) [with int_type_ = unsigned int; boost::date_time::int_adapter&lt;int_type_&gt; = boost::date_time::int_adapter&lt;unsigned int&gt;]':| C:\Program Files\C++\Boost\boost\date_time\gregorian\greg_date.hpp|53|required from here| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'NumSpecialValues' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp||In instantiation of 'static boost::date_time::int_adapter&lt;int_type_&gt; boost::date_time::int_adapter&lt;int_type_&gt;::from_special(boost::date_time::special_values) [with int_type_ = long int; boost::date_time::int_adapter&lt;int_type_&gt; = boost::date_time::int_adapter&lt;long int&gt;]':| C:\Program Files\C++\Boost\boost\date_time\date_duration.hpp|42|required from 'boost::date_time::date_duration&lt;duration_rep_traits&gt;::date_duration(boost::date_time::special_values) [with duration_rep_traits = boost::date_time::duration_traits_adapted]'| C:\Program Files\C++\Boost\boost\date_time\gregorian\greg_duration.hpp|39|required from here| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'NumSpecialValues' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp||In instantiation of 'static boost::date_time::int_adapter&lt;int_type_&gt; boost::date_time::int_adapter&lt;int_type_&gt;::from_special(boost::date_time::special_values) [with int_type_ = long long int; boost::date_time::int_adapter&lt;int_type_&gt; = boost::date_time::int_adapter&lt;long long int&gt;]':| C:\Program Files\C++\Boost\boost\date_time\time_duration.hpp|69|required from 'boost::date_time::time_duration&lt;T, rep_type&gt;::time_duration(boost::date_time::special_values) [with T = boost::posix_time::time_duration; rep_type = boost::date_time::time_resolution_traits&lt;boost::date_time::time_resolution_traits_adapted64_impl, (boost::date_time::time_resolutions)5u, 1000000ll, 6u&gt;]'| C:\Program Files\C++\Boost\boost\date_time\posix_time\posix_time_config.hpp|82|required from here| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'NumSpecialValues' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\time_system_counted.hpp||In instantiation of 'static boost::date_time::counted_time_system&lt;time_rep&gt;::time_rep_type boost::date_time::counted_time_system&lt;time_rep&gt;::get_time_rep(boost::date_time::special_values) [with time_rep = boost::date_time::counted_time_rep&lt;boost::posix_time::millisec_posix_time_system_config&gt;; boost::date_time::counted_time_system&lt;time_rep&gt;::time_rep_type = boost::date_time::counted_time_rep&lt;boost::posix_time::millisec_posix_time_system_config&gt;]':| C:\Program Files\C++\Boost\boost\date_time\time.hpp|67|required from 'boost::date_time::base_time&lt;T, time_system&gt;::base_time(boost::date_time::special_values) [with T = boost::posix_time::ptime; time_system = boost::date_time::counted_time_system&lt;boost::date_time::counted_time_rep&lt;boost::posix_time::millisec_posix_time_system_config&gt; &gt;]'| C:\Program Files\C++\Boost\boost\date_time\posix_time\ptime.hpp|51|required from here| C:\Program Files\C++\Boost\boost\date_time\time_system_counted.hpp|149|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]| C:\Program Files\C++\Boost\boost\date_time\time_system_counted.hpp|149|warning: enumeration value 'NumSpecialValues' not handled in switch [-Wswitch-enum]| </pre><p> Also boost::thread has a linker dependency to boost::date_time on VC10 and VC11 (but not on GCC). It was indicated in the other ticket this might not be intended. </p> <p> Regards, <a class="missing wiki">ZenJu</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7068 Trac 1.4.3 ZenJu <zhnmju123@…> Tue, 03 Jul 2012 20:02:40 GMT cc set https://svn.boost.org/trac10/ticket/7068#comment:1 https://svn.boost.org/trac10/ticket/7068#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">zhnmju123@…</span> added </li> </ul> Ticket Marshall Clow Tue, 03 Jul 2012 22:11:19 GMT <link>https://svn.boost.org/trac10/ticket/7068#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7068#comment:2</guid> <description> <p> Ok. I looked at these warnings, and they are all bogus. For example, in int_adapter.hpp, we have: </p> <pre class="wiki">72: switch (sv) { 73: case not_a_date_time: return not_a_number(); 74: case neg_infin: return neg_infinity(); 75: case pos_infin: return pos_infinity(); 76: case max_date_time: return (max)(); 77: case min_date_time: return (min)(); 78: default: return not_a_number(); 79: } </pre><p> which (apparently) gives an error of: <code>C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]|</code> </p> <p> That's absurd. <code>not_special</code> is definitely handled here; it's spelled <code>default</code>. </p> <p> conversion.hpp(33) - this problem.<br /> int_adapter.hpp(75) - this problem.<br /> time_system_counted.hpp(149) - this problem.<br /> </p> <p> I suggest that you turn off this warning and report it as a bug against gcc. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 01 Aug 2012 04:09:21 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7068#comment:3 https://svn.boost.org/trac10/ticket/7068#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> Ticket andrewtrapani@… Sat, 12 Sep 2015 00:53:00 GMT <link>https://svn.boost.org/trac10/ticket/7068#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7068#comment:4</guid> <description> <p> Hi, </p> <p> I ran across this today and wanted to offer an opinion. In the example above by marshall, the default catches everything not listed and returns NaN. </p> <p> Now if we add a new enum value "foobar", it will automatically return NaN. But what if we forgot to edit the above switch when we actually needed foobar to return foobar_value() as in some value other than NaN? </p> <p> The flipside is now we are forcing the coder to write out all of the cases. </p> <pre class="wiki"> switch (sv) { case not_a_date_time: return not_a_number(); case neg_infin: return neg_infinity(); case pos_infin: return pos_infinity(); case max_date_time: return (max)(); case min_date_time: return (min)(); case foobar: return foobar_value(); case foo: case bar: case fizz: //and so on all fall into default or else we get a bunch of warnings default: return not_a_number(); } </pre><p> It looks like this feature is not ready for usage unless something changes about the enum declaration options in newer C++ version. </p> </description> <category>Ticket</category> </item> </channel> </rss>