Boost logo

Boost Testing :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2005-06-02 08:25:34

On 6/2/05, Victor A. Wagner Jr. <vawjr_at_[hidden]> wrote:

> One has to wonder why the test functions in 7.1 then and fails in
> 8.0. Surely you don't imply that the older libraries were "better".

The VS2005 runtime has deprecated many "standard" facilities that are
either unsafe or prone to overflow, localtime() among them. The
deprecated functions now either have 64-bit analogs or *_s (safe)
versions. It seems that as part of this, MS has added asserting range
checks on the values passed to functions like localtime (really
_localtime64_s down deep).

Attached is a simple test program that illustrates the behavior of
localtime using extreme values of time_t (-1,
numeric_limits<time_t>::min(), etc).

It runs without generating any errors on Visual Studio .NET 2003,
though the return values of localtime are NULL when the time_t
argument is <0. Output:

0=1969-12-31 19:00:00
1117718711=2005-06-02 09:25:11
2147483647=2038-01-18 22:14:07
2147483647=2038-01-18 22:14:07

With VS2005, an exception is thrown from _localtime64_s when a
negative value is passed to localtime, terminating the program.
Here's the pertinent info from the popup I see when compiled with

Program: c:\dev\c++\time\time.exe
File: loctim64.c
Line: 80
Expression: ( ( *ptime >= 0) && (*ptime <= _MAX__TIME64_T ) )

This happens with the non-debug runtime as well, though the popup is
less informative.

Caleb Epstein
caleb dot epstein at gmail dot com

Boost-testing list run by mbergal at