Inconvenience in time_parsing.hpp - uninit variables
I was trying to use the date_time ptime functions with ISO syle input (boost 1.30.2 with MSVC++6 SP5). The function parse_undelimited_time_duration in time_parsing has three short variables hours, min, and sec that are uninitialized which lead to unpredictable results. These are at line 99. I stumbled on to this when I passed a string "20011027T0202" to ptime(from_iso_string()). To my surprise when I printed the value out it came back as 20011026T222345! The code works OK as is if you always pass a full HHMMSS. This must have been found in parse_delimited_time_duration as it has unsigned shorts that are intialized to zero.
On Fri, 29 Aug 2003 22:52:59 +0000, Larry Knain wrote
I was trying to use the date_time ptime functions with ISO syle input (boost 1.30.2 with MSVC++6 SP5). The function parse_undelimited_time_duration in time_parsing has three short variables hours, min, and sec that are uninitialized which lead to unpredictable results. These are at line 99. I stumbled on to this when I passed a string "20011027T0202" to ptime(from_iso_string()). To my surprise when I printed the value out it came back as 20011026T222345! The code works OK as is if you always pass a full HHMMSS. This must have been found in parse_delimited_time_duration as it has unsigned shorts that are intialized to zero.
Fixed in CVS. I also checked in a test case that doesn't pass a full duration on the time string. Thx, Jeff
participants (2)
-
Jeff Garland
-
Larry Knain