Skip to content

Commit ebc9fba

Browse files
committed
New issue from Jiang An: "Is member is_steady of a Cpp17Clock type required to be usable in constant expressions?"
1 parent ab8c7e4 commit ebc9fba

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

xml/issue4487.xml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4487" status="New">
5+
<title>Is member `is_steady` of a <i>Cpp17Clock</i> type required to be usable in constant expressions?</title>
6+
<section><sref ref="[time.clock.req]"/></section>
7+
<submitter>Jiang An</submitter>
8+
<date>26 Nov 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
In <sref ref="[time.clock.req]"/>/[tab:time.clock], the static data member `C1::is_steady` seemingly
14+
indicates the property of the clock statically, as the requirements say "always".
15+
<p/>
16+
However, it is not clear whether `C1::steady` should be usable in a constant expression. A hostile
17+
reading may indicate that it is allowed to make `C1::steady` only defined in some separated translated
18+
unit and/or initialized from some non-constant expression.
19+
<p/>
20+
Also, it is not very clear that the "always" means the conditions always hold in all executions,
21+
or only always hold in the current execution. The latter reading allows `C1::steady` to vary between
22+
executions.
23+
</p>
24+
</discussion>
25+
26+
<resolution>
27+
<p>
28+
This wording is relative to <paper num="N5032"/>.
29+
</p>
30+
31+
<blockquote class="note">
32+
<p>
33+
[<i>Drafting Note:</i> Two mutually exclusive options are prepared, depicted below by <b>Option A</b> and
34+
<b>Option B</b>, respectively.]
35+
</p>
36+
</blockquote>
37+
38+
<p>
39+
<b>Option A</b>: Requiring usability in constant expressions.
40+
</p>
41+
42+
<ol>
43+
<li><p>Modify Table [tab:time.clock] &mdash; <i>Cpp17Clock</i> requirements as indicated:</p>
44+
45+
<blockquote>
46+
<table border="1">
47+
<caption>Table 131 &mdash; <i>Cpp17Clock</i> requirements [tab:time.clock]</caption>
48+
<tr align="center">
49+
<th>Expression</th>
50+
<th>Return type</th>
51+
<th>Operational semantics</th>
52+
</tr>
53+
54+
<tr>
55+
<td colspan="4" align="center">
56+
<tt>[&hellip;]</tt>
57+
</td>
58+
</tr>
59+
60+
<tr>
61+
<td>
62+
<tt>C1::is_steady</tt>
63+
</td>
64+
<td>
65+
<tt>const bool</tt>
66+
</td>
67+
<td>
68+
`true` if <tt>t1 &lt;= t2</tt> is always
69+
`true` and the time between<br/>
70+
clock ticks is constant,<br/>
71+
otherwise `false`.<br/>
72+
<ins>`C1::is_steady` shall be usable in constant expressions (<sref ref="[expr.const]"/>).</ins>
73+
</td>
74+
</tr>
75+
76+
<tr>
77+
<td colspan="4" align="center">
78+
<tt>[&hellip;]</tt>
79+
</td>
80+
</tr>
81+
82+
</table>
83+
84+
</blockquote>
85+
</li>
86+
87+
</ol>
88+
89+
90+
<p>
91+
<b>Option B</b>: Allowing varying between executions.
92+
</p>
93+
94+
<ol>
95+
<li><p>Modify Table [tab:time.clock] &mdash; <i>Cpp17Clock</i> requirements as indicated:</p>
96+
97+
<blockquote>
98+
<table border="1">
99+
<caption>Table 131 &mdash; <i>Cpp17Clock</i> requirements [tab:time.clock]</caption>
100+
<tr align="center">
101+
<th>Expression</th>
102+
<th>Return type</th>
103+
<th>Operational semantics</th>
104+
</tr>
105+
106+
<tr>
107+
<td colspan="4" align="center">
108+
<tt>[&hellip;]</tt>
109+
</td>
110+
</tr>
111+
112+
<tr>
113+
<td>
114+
<tt>C1::is_steady</tt>
115+
</td>
116+
<td>
117+
<tt>const bool</tt>
118+
</td>
119+
<td>
120+
`true` if <tt>t1 &lt;= t2</tt> is always
121+
`true` and the time between<br/>
122+
clock ticks is constant<br/>
123+
<ins>for the duration of the current program execution</ins>,<br/>
124+
otherwise `false`.<br/>
125+
<ins>[<i>Note</i> ?: `C1::is_steady` is not required to be usable in constant expressions
126+
(<sref ref="[expr.const]"/>) and can vary between different executions. &mdash; <i>end note</i>]</ins>
127+
</td>
128+
</tr>
129+
130+
<tr>
131+
<td colspan="4" align="center">
132+
<tt>[&hellip;]</tt>
133+
</td>
134+
</tr>
135+
136+
</table>
137+
138+
</blockquote>
139+
</li>
140+
</ol>
141+
142+
</resolution>
143+
144+
</issue>

0 commit comments

Comments
 (0)