935. clock error handling needs to be specified

Section: 23.17.7 [time.clock] Status: LEWG Submitter: Beman Dawes Opened: 2008-11-24 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with LEWG status.

Discussion:

Each of the three clocks specified in Clocks 23.17.7 [time.clock] provides the member function:

static time_point now();

The semantics specified by Clock requirements 23.17.3 [time.clock.req] make no mention of error handling. Thus the function may throw bad_alloc or an implementation-defined exception (20.5.5.12 [res.on.exception.handling] paragraph 4).

Some implementations of these functions on POSIX, Windows, and presumably on other operating systems, may fail in ways only detectable at runtime. Some failures on Windows are due to supporting chipset errata and can even occur after successful calls to a clock's now() function.

These functions are used in cases where exceptions are not appropriate or where the specifics of the exception or cause of error need to be available to the user. See N2828, Library Support for hybrid error handling (Rev 1), for more specific discussion of use cases. Thus some change in the interface of now is required.

The proposed resolution has been implemented in the Boost version of the chrono library. No problems were encountered.

[ Batavia (2009-05): ]

We recommend this issue be deferred until the next Committee Draft has been issued and the prerequisite paper has been accepted.

Move to Open.

[ 2009-10 Santa Cruz: ]

Mark as NAD future. Too late to make this change without having already accepted the hybrid error handling proposal.

Proposed resolution:

Accept the proposed wording of N2828, Library Support for hybrid error handling (Rev 1).

Change Clock requirements 23.17.3 [time.clock.req] as indicated:

-2- In Table 55 C1 and C2 denote clock types. t1 and t2 are values returned by C1::now() where the call returning t1 happens before (1.10) the call returning t2 and both of these calls happen before C1::time_point::max(). ec denotes an object of type error_code (22.5.3.1 [syserr.errcode.overview]).

Table 55 — Clock requirements
ExpressionReturn typeOperational semantics
... ... ...
C1::now() C1::time_point Returns a time_point object representing the current point in time.
C1::now(ec) C1::time_point Returns a time_point object representing the current point in time.

Change class system_clock 23.17.7.1 [time.clock.system] as indicated:

static time_point now(error_code& ec=throws());

Change class monotonic_clock 99 [time.clock.monotonic] as indicated:

static time_point now(error_code& ec=throws());

Change class high_resolution_clock 23.17.7.3 [time.clock.hires] as indicated:

static time_point now(error_code& ec=throws());