Boost logo

Boost :

Subject: [boost] boost::gregorian::to_tm() initializes some fields of struct tm, but not all
From: Dmitry Goncharov (dgoncharov_at_[hidden])
Date: 2009-02-07 09:43:28


Hi,

boost::gregorian::to_tm() initializes some fields of struct tm, but not
all. Implementations keep there additional fields.
Besides the fields defined by POSIX libc2.9 has two additional fields in
struct tm:
struct tm
{
...
#ifdef __USE_BSD
  long int tm_gmtoff; /* Seconds east of UTC. */
  __const char *tm_zone; /* Timezone abbreviation. */
#else
  long int __tm_gmtoff; /* Seconds east of UTC. */
  __const char *__tm_zone; /* Timezone abbreviation. */
#endif
};

There are two additional fields tm_gmtoff and tm_zone.
boost::gregorian::to_tm() does not initialize tm_zone and tm_gmtoff.
There are functions as well which use these additional fields.
E.g. this is a piece of code from the implementation of strftime() from
libc2.9:

static size_t
__strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
...
{
...
  zone = (const char *) tp->tm_zone;
#endif
#if HAVE_TZNAME
  if (ut)
    {
      if (! (zone && *zone))
    zone = "GMT";
    }
...
}
This function dereferences tp->tm_zone.

I have not created a ticker since this could be an already known issue.

BR, Dmitry
 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk