<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 935: clock error handling needs to be specified</title>
<meta property="og:title" content="Issue 935: clock error handling needs to be specified">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue935.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD">NAD</a> status.</em></p>
<h3 id="935"><a href="lwg-closed.html#935">935</a>. clock error handling needs to be specified</h3>
<p><b>Section:</b> 30.7 <a href="https://wg21.link/time.clock">[time.clock]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> Beman Dawes <b>Opened:</b> 2008-11-24 <b>Last modified:</b> 2019-02-26</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Each of the three clocks specified in Clocks 30.7 <a href="https://wg21.link/time.clock">[time.clock]</a>
provides the member function:
</p>

<blockquote><pre>
static time_point now();
</pre></blockquote>

<p>
The semantics specified by Clock requirements 30.3 <a href="https://wg21.link/time.clock.req">[time.clock.req]</a>
make no mention of error handling. Thus the function may throw <code>bad_alloc</code>
or an implementation-defined exception (16.4.6.14 <a href="https://wg21.link/res.on.exception.handling">[res.on.exception.handling]</a>
paragraph 4).
</p>

<p>
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 <code>now()</code>
function.
</p>

<p>
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
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2828.html">N2828</a>,
<i>Library Support for hybrid error
handling (Rev 1)</i>, for more specific discussion of use cases. Thus some change in
the interface of now is required.
</p>

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

<p><i>[
Batavia (2009-05):
]</i></p>

<blockquote>
<p>
We recommend this issue be deferred until the next Committee Draft
has been issued and the prerequisite paper has been accepted.
</p>
<p>
Move to Open.
</p>
</blockquote>

<p><i>[
2009-10 Santa Cruz:
]</i></p>


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

<p><i>[LEWG Kona 2017]</i></p>

<p>Recommend NAD. Needs a paper. Proposed resolution no longer applies.</p>


<p id="res-935"><b>Proposed resolution:</b></p>
<p>
Accept the proposed wording of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2828.html">N2828</a>,
<i>Library Support for hybrid error handling (Rev 1)</i>.
</p>

<p>
Change <code>Clock</code> requirements 30.3 <a href="https://wg21.link/time.clock.req">[time.clock.req]</a> as indicated:
</p>

<blockquote>
<p>
-2- In Table 55 <code>C1</code> and <code>C2</code> denote clock types. <code>t1</code> and
<code>t2</code> are values returned by <code>C1::now()</code> where the call 
returning <code>t1</code> happens before (1.10) the call returning <code>t2</code> and
both of these calls happen before <code>C1::time_point::max()</code>.
<ins><code>ec</code> denotes an object of type <code>error_code</code> 
(19.5.4.1 <a href="https://wg21.link/syserr.errcode.overview">[syserr.errcode.overview]</a>).</ins>
</p>

<table border="1">
<caption>Table 55 &mdash; Clock requirements</caption>
<tr>
<th>Expression</th><th>Return type</th><th>Operational semantics</th>
</tr>

<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>

<tr>
<td><code>C1::now()</code></td>
<td><code>C1::time_point</code></td>
<td>Returns a <code>time_point</code> object representing the current point in time.
</td>
</tr>

<tr>
<td><code><ins>C1::now(ec)</ins></code></td>
<td><code><ins>C1::time_point</ins></code></td>
<td><ins>Returns a <code>time_point</code> object representing the current point in time.</ins>
</td>
</tr>
</table>
</blockquote>

<p>
Change class <code>system_clock</code> 30.7.2 <a href="https://wg21.link/time.clock.system">[time.clock.system]</a> as indicated:
</p>

<blockquote><pre>
static time_point now(<ins>error_code&amp; ec=throws()</ins>);
</pre></blockquote>

<p>
Change class <code>monotonic_clock</code> 99 [time.clock.monotonic] as indicated:
</p>

<blockquote><pre>
static time_point now(<ins>error_code&amp; ec=throws()</ins>);
</pre></blockquote>

<p>
Change class <code>high_resolution_clock</code> 30.7.8 <a href="https://wg21.link/time.clock.hires">[time.clock.hires]</a> as indicated:
</p>

<blockquote><pre>
static time_point now(<ins>error_code&amp; ec=throws()</ins>);
</pre></blockquote>






</body>
</html>
