Modify

Ticket #8696 (closed Bugs: fixed)

Opened 10 months ago

Last modified 6 days ago

chrono compilation error on Solaris/gcc

Reported by: tmmikolajczyk@… Owned by: viboes
Milestone: Boost 1.54.0 Component: chrono
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

The "timegm" function is not available on Solaris (Solaris 11) when using the gcc toolchain. It works fine for the sunpro toolchain. The "timegm" manual on regular linux says (man timegm):

"

For a portable version of timegm(), set the TZ environment variable to UTC, call mktime(3) and restore the value of TZ. Something like

#include <time.h> #include <stdlib.h>

time_t my_timegm(struct tm *tm) {

time_t ret; char *tz;

tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz)

setenv("TZ", tz, 1);

else

unsetenv("TZ");

tzset(); return ret;

}

"

The Boost.Chrono has its own implementation available as the internal_timegm() function, however the implementation is used only in very limited cases (currently Windows but not Cygwin env.) selected by the BOOST_CHRONO_INTERNAL_TIMEGM macrodefinition. The proposed patch enables the internal_timegm() also for Solaris/gcc. The issue concerns chrono in version 2 (BOOST_CHRONO_VERSION=2).

The attached application reproduces the issue:

$ g++ chrono_io_test_solaris.cpp -lboost_system -DBOOST_CHRONO_VERSION=2 In file included from boost/chrono/chrono_io.hpp:26:0,

from chrono_io_test_solaris.cpp:1:

boost/chrono/io/time_point_io.hpp: In function 'std::basic_istream<_CharT, _Traits>& boost::chrono::operator>>(std::basic_istream<_CharT, _Traits>&, boost::chrono::time_point<boost::chrono::system_clock, Duration>&)': boost/chrono/io/time_point_io.hpp:1003:27: error: there are no arguments to 'timegm' that depend on a template parameter, so a declaration of 'timegm' must be available boost/chrono/io/time_point_io.hpp:1003:27: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) boost/chrono/io/time_point_io.hpp:1055:29: error: there are no arguments to 'timegm' that depend on a template parameter, so a declaration of 'timegm' must be available $

Attachments

bug_8696.patch Download (652 bytes) - added by tmmikolajczyk@… 10 months ago.
patch
chrono_io_test_solaris.cpp Download (156 bytes) - added by tmmikolajczyk@… 10 months ago.
application to reproduce the issue

Change History

Changed 10 months ago by tmmikolajczyk@…

patch

Changed 10 months ago by tmmikolajczyk@…

application to reproduce the issue

comment:1 Changed 10 months ago by viboes

  • Status changed from new to assigned
  • Milestone changed from To Be Determined to Boost 1.54.0

Thanks for the patch.

comment:2 Changed 10 months ago by viboes

Committed revision [84790].

comment:3 Changed 10 months ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [84793]) Chrono: fix #8691,#8696 and update history.

comment:4 Changed 6 days ago by Stephen Clamage <stephen.clamage@…>

The original ticket description claims that timegm is available when using the sunpro toolchain on Solaris 11. That claim is not correct, and even with this bug fix the code does not work with the sunpro toolchain. I filed new ticket 9918 for this problem.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.