Non-reentrant implementation of data_time/c_time.hpp under MS-Windows VC 8.0

Hi guys, In the code below, there are three severe bugs: 1. The addition of the #pragma warning instead of using the localtime_s() and gmtime_s() functions which are similar to the localtime_r() and gmtime_r() functions (the parameters are swapped.) Thus, if _MSC_VER >= 1400, you need a new implementation with the "safe" versions. 2. The documentation says: //! requires a pointer to a user created std::tm struct because the function is expected to WRITE in that buffer. At this time, it does not do so and if you don't use the returned pointer, the pointer to the user defined tm struct is useless. You are missing a couple of asterisks in there! *result = *std::localtime(t); 3. In a multi-thread environment, which you detect with some BOOST_THREAD_ENABLED flag, you must use a scoped lock to protect these calls. Lock, call, return is what I'd expect to see here (is it prohibited for the c_time.hpp file to include the thread lock mechanism?) I hope I will see these three bugs fixed in a future version. Thank you, Alexis Wilke P.S. I tried to post this text to your Trac system and it was rejected by Akismet. According to them, it is spam. #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) #pragma warning(push) // preserve warning settings #pragma warning(disable : 4996) // disable depricated localtime/gmtime warning on vc8 #endif // _MSC_VER >= 1400 //! requires a pointer to a user created std::tm struct inline static std::tm* localtime(const std::time_t* t, std::tm* result) { result = std::localtime(t); return result; } //! requires a pointer to a user created std::tm struct inline static std::tm* gmtime(const std::time_t* t, std::tm* result) { result = std::gmtime(t); return result; } #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) #pragma warning(pop) // restore warnings to previous state #endif // _MSC_VER >= 1400 ------------ Alexis Wilke President Made to Order Software, Corporation e-mail: alexis@m2osw.com cell-text: alexis.cell@m2osw.com (please, only small messages) Web Pages: http://www.m2osw.com http://www.turnwatcher.com Company e-mail: contact@m2osw.com Phone: +(1) 916 220 6482 Fax: +(1) 916 988 1450 Address: 9275 Blue Oak Drive Orangevale, California 95662 United States of America CONFIDENTIAL This document contains non-public proprietary information that is subject to restrictions on use and/or disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this e-mail message in error, please e-mail the sender and delete all copies. Thank you.
participants (1)
-
Alexis Wilke