time_duration compile warning
Hello, I'm using GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9), and the time_duration class was generating the following warning for me: /usr/local/include/boost/boost/date_time/time_duration.hpp:58: warning: control may reach end of non-void function I've heard that I wasn't the first person with this problem, and well, since I like my code to compile clean (treat warnings as errors), this was preventing me to do so. Apparently GCC had some troubles with seeing that the static tick_type to_tick_count () function defined at time_resolution_traits.hpp was always returning something. Simply moving the code inside the else {} block to the end of the function made GCC confident that the function was indeed always returning something. Looks more like a GCC bug, but here's the patch: root@solatis1:/usr/local/include/boost/boost/date_time# diff time_resolution_traits.hpp time_resolution_traits.hpp~ 123,125c123,127 < return (((fractional_seconds_type(hours)*3600) < + (fractional_seconds_type(minutes)*60) < + seconds)*res_adjust()) + fs; ---
else{ return (((fractional_seconds_type(hours)*3600) + (fractional_seconds_type(minutes)*60) + seconds)*res_adjust()) + fs; }
root@solatis1:/usr/local/include/boost/boost/date_time# This is for boost 1.33.1 Regards, Leon Mergen http://www.solatis.com
Leon Mergen wrote:
Hello,
Hi, sorry for the slow reply...
I'm using GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9), and the time_duration class was generating the following warning for me:
/usr/local/include/boost/boost/date_time/time_duration.hpp:58: warning: control may reach end of non-void function
I've heard that I wasn't the first person with this problem, and well, since I like my code to compile clean (treat warnings as errors), this was preventing me to do so.
Apparently GCC had some troubles with seeing that the static tick_type to_tick_count () function defined at time_resolution_traits.hpp was always returning something. Simply moving the code inside the else {} block to the end of the function made GCC confident that the function was indeed always returning something. Looks more like a GCC bug, but here's the patch:
I'll try to apply the patch in the near future -- I'll let you know when I do. However, please submit a gcc bug as this is clearly a compiler bug. Jeff
Jeff Garland wrote:
Apparently GCC had some troubles with seeing that the static tick_type to_tick_count () function defined at time_resolution_traits.hpp was always returning something. Simply moving the code inside the else {} block to the end of the function made GCC confident that the function was indeed always returning something. Looks more like a GCC bug, but here's the patch:
I'll try to apply the patch in the near future -- I'll let you know when I do. However, please submit a gcc bug as this is clearly a compiler bug.
Hello Jeff, Will do, thanks for your reply. Regards, Leon Mergen http://www.solatis.com
participants (2)
-
Jeff Garland
-
Leon Mergen