[Boost-bugs] [Boost C++ Libraries] #7160: BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG and DATE_TIME_NO_DEFAULT_CONSTRUCTOR

Subject: [Boost-bugs] [Boost C++ Libraries] #7160: BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG and DATE_TIME_NO_DEFAULT_CONSTRUCTOR
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-23 14:31:00


#7160: BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG and DATE_TIME_NO_DEFAULT_CONSTRUCTOR
-----------------------------------------------------------+----------------
 Reporter: Ricky Stoneback <rwstoneback@…> | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: thread, asio, ptime, posix_time |
-----------------------------------------------------------+----------------
 I think I found a couple issues that are somewhat related to one another:

 '''Issue 1 - Defining BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG and using the
 ptime default constructor along with a thread causes runtime crash'''

 Steps to reproduce:
 1. Define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG (to use nanosecond
 resolution in a posix_time) in the pre-processor definitions (VS2008).
 2. Create a boost::posix_time::ptime using the default constructor.
 3. Create a boost::thread and call join.
 Example:
 {{{
 #include <iostream>
 #include <boost/thread.hpp>

 class ThreadClass
 {
    public:
         ThreadClass()
         {
         }

         void operator()()
         {
            return;
         }
 };


 int main()
 {
         boost::posix_time::ptime currentTimeUTC;

         ThreadClass tc;
         boost::thread t(tc);
         t.join(); //causes a runtime access violation here

         std::cout << "done" << std::endl;
         system("pause");

         return 0;
 }
 }}}

 '''Issue 2 - defining DATE_TIME_NO_DEFAULT_CONSTRUCTOR causes compile-time
 error "no appropriate default constructor available"'''

 In Issue 1 above, if you do not use a default constructor for a ptime, it
 seems to fix the issue. So I figured that was fine and I could prevent a
 user of my library from using that default constructor by defining
 DATE_TIME_NO_DEFAULT_CONSTRUCTOR. However, this now breaks at compile
 time:

 Steps to reproduce:
 1. Use the same code as above, just for ease of use.
 2. Define the pre-processor definition: DATE_TIME_NO_DEFAULT_CONSTRUCTOR.
 3. Compile the program.
 4. The following error is produced: error C2512:
 'boost::posix_time::ptime' : no appropriate default constructor available
 e:\libraries\boost\boost_1_47\boost\thread\win32\thread_data.hpp 145

 The issue, I believe, is that I am using a boost thread, which uses a
 ptime default constructor in its ''explicit timeout(sentinal_type)''
 constructor when it doesn't set the ''abs_time'' member variable.


 I am using Boost 1.47, however looking at the latest boost code (1.51), I
 don't see any fixes for these issues that stand out (I am not able to try
 the latest versions of Boost, so I apologize if they are fixed, but I
 would think that they are not)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7160>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC