#7068 closed Bugs (invalid)
Compiler warnings in date_time
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | To Be Determined | Component: | date_time |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | Cc: | zhnmju123@… |
Description
In reference to: https://svn.boost.org/trac/boost/ticket/7045
The following warnings are issued for GCC 4.6 and 4.7 both MinGW and Linux GCC with "-wall" for boost 1.50:
C:\Program Files\C++\Boost\boost\date_time\gregorian\conversion.hpp||In function 'tm boost::gregorian::to_tm(const boost::gregorian::date&)':| 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<int_type_> boost::date_time::int_adapter<int_type_>::from_special(boost::date_time::special_values) [with int_type_ = unsigned int; boost::date_time::int_adapter<int_type_> = boost::date_time::int_adapter<unsigned int>]':| 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<int_type_> boost::date_time::int_adapter<int_type_>::from_special(boost::date_time::special_values) [with int_type_ = long int; boost::date_time::int_adapter<int_type_> = boost::date_time::int_adapter<long int>]':| C:\Program Files\C++\Boost\boost\date_time\date_duration.hpp|42|required from 'boost::date_time::date_duration<duration_rep_traits>::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<int_type_> boost::date_time::int_adapter<int_type_>::from_special(boost::date_time::special_values) [with int_type_ = long long int; boost::date_time::int_adapter<int_type_> = boost::date_time::int_adapter<long long int>]':| C:\Program Files\C++\Boost\boost\date_time\time_duration.hpp|69|required from 'boost::date_time::time_duration<T, rep_type>::time_duration(boost::date_time::special_values) [with T = boost::posix_time::time_duration; rep_type = boost::date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, (boost::date_time::time_resolutions)5u, 1000000ll, 6u>]'| 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<time_rep>::time_rep_type boost::date_time::counted_time_system<time_rep>::get_time_rep(boost::date_time::special_values) [with time_rep = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>; boost::date_time::counted_time_system<time_rep>::time_rep_type = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>]':| C:\Program Files\C++\Boost\boost\date_time\time.hpp|67|required from 'boost::date_time::base_time<T, time_system>::base_time(boost::date_time::special_values) [with T = boost::posix_time::ptime; time_system = boost::date_time::counted_time_system<boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config> >]'| 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]|
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.
Regards, ZenJu
Change History (4)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 7 years ago
Hi,
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.
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?
The flipside is now we are forcing the coder to write out all of the cases.
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(); }
It looks like this feature is not ready for usage unless something changes about the enum declaration options in newer C++ version.
Ok. I looked at these warnings, and they are all bogus. For example, in int_adapter.hpp, we have:
which (apparently) gives an error of:
C:\Program Files\C++\Boost\boost\date_time\int_adapter.hpp|75|warning: enumeration value 'not_special' not handled in switch [-Wswitch-enum]|
That's absurd.
not_special
is definitely handled here; it's spelleddefault
.conversion.hpp(33) - this problem.
int_adapter.hpp(75) - this problem.
time_system_counted.hpp(149) - this problem.
I suggest that you turn off this warning and report it as a bug against gcc.