Skip to content

Commit 761db3c

Browse files
committed
[P2996] Rejecting size_of(bitfield)
1 parent d645d9c commit 761db3c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

2996_reflection/d2996r12.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,9 @@ <h1 data-number="1" style="border-bottom:1px solid #cccccc" id="revision-history
10901090
<ul>
10911091
<li>improve specification of <code class="sourceCode cpp">access_context<span class="op">::</span>current<span class="op">()</span></code>
10921092
(including examples)</li>
1093+
<li><code class="sourceCode cpp">size_of<span class="op">(</span>r<span class="op">)</span></code>
1094+
is no longer constant if <code class="sourceCode cpp">r</code> is a
1095+
bit-field</li>
10931096
</ul></li>
10941097
</ul>
10951098
<p>Since <span class="citation" data-cites="P2996R10"><a href="https://wg21.link/p2996r10" role="doc-biblioref">[P2996R10]</a></span>:</p>
@@ -13473,8 +13476,14 @@ <h3 class="unnumbered" id="meta.reflection.layout-reflection-layout-queries">[me
1347313476
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_629" id="pnum_629">5</a></span>
1347413477
<em>Constant When</em>: <code class="sourceCode cpp">dealias<span class="op">(</span>r<span class="op">)</span></code>
1347513478
is a reflection of a type, object, value, variable of non-reference
13476-
type, non-static data member, direct base class relationship, or data
13477-
member description. If <code class="sourceCode cpp">dealias<span class="op">(</span>r<span class="op">)</span></code>
13479+
type, non-static data member that is not a bit-field, direct base class
13480+
relationship, or data member description
13481+
(<code class="sourceCode cpp"><em>T</em></code>,
13482+
<code class="sourceCode cpp"><em>N</em></code>,
13483+
<code class="sourceCode cpp"><em>A</em></code>,
13484+
<code class="sourceCode cpp"><em>W</em></code>,
13485+
<code class="sourceCode cpp"><em>NUA</em></code>) ([class.mem.general])
13486+
where <code class="sourceCode cpp"><em>W</em></code> is not ⊥. If <code class="sourceCode cpp">dealias<span class="op">(</span>r<span class="op">)</span></code>
1347813487
represents a type, then <code class="sourceCode cpp">is_complete_type<span class="op">(</span>r<span class="op">)</span></code>
1347913488
is <code class="sourceCode cpp"><span class="kw">true</span></code>.</p>
1348013489
<p><span class="marginalizedparent"><a class="marginalized" href="#pnum_630" id="pnum_630">6</a></span>
@@ -13485,8 +13494,7 @@ <h3 class="unnumbered" id="meta.reflection.layout-reflection-layout-queries">[me
1348513494
<code class="sourceCode cpp"><em>N</em></code>,
1348613495
<code class="sourceCode cpp"><em>A</em></code>,
1348713496
<code class="sourceCode cpp"><em>W</em></code>,
13488-
<code class="sourceCode cpp"><em>NUA</em></code>) ([class.mem.general]),
13489-
or <code class="sourceCode cpp">dealias<span class="op">(</span>r<span class="op">)</span></code>
13497+
<code class="sourceCode cpp"><em>NUA</em></code>), or <code class="sourceCode cpp">dealias<span class="op">(</span>r<span class="op">)</span></code>
1349013498
represents a type <code class="sourceCode cpp"><em>T</em></code>, then
1349113499
<code class="sourceCode cpp"><span class="kw">sizeof</span><span class="op">(</span><em>LAT</em><span class="op">)</span></code>
1349213500
where <code class="sourceCode cpp"><em>LAT</em></code> is the

2996_reflection/reflection.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Since [@P2996R11]:
3333
* disallow reflection of local parameters introduced by `$requires-expression$`s
3434
* library wording updates
3535
* improve specification of `access_context::current()` (including examples)
36+
* `size_of(r)` is no longer constant if `r` is a bit-field
3637

3738
Since [@P2996R10]:
3839

@@ -7568,9 +7569,9 @@ consteval member_offset offset_of(info r);
75687569
consteval size_t size_of(info r);
75697570
```
75707571

7571-
[#]{.pnum} *Constant When*: `dealias(r)` is a reflection of a type, object, value, variable of non-reference type, non-static data member, direct base class relationship, or data member description. If `dealias(r)` represents a type, then `is_complete_type(r)` is `true`.
7572+
[#]{.pnum} *Constant When*: `dealias(r)` is a reflection of a type, object, value, variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or data member description (`$T$`, `$N$`, `$A$`, `$W$`, `$NUA$`) ([class.mem.general]) where `$W$` is not ⊥. If `dealias(r)` represents a type, then `is_complete_type(r)` is `true`.
75727573

7573-
[#]{.pnum} *Returns*: If `r` represents a non-static data member of type `$T$`, a data member description (`$T$`, `$N$`, `$A$`, `$W$`, `$NUA$`) ([class.mem.general]), or `dealias(r)` represents a type `$T$`, then `sizeof($LAT$)` where `$LAT$` is the layout-associated type ([class.member.general]) of a non-static data member of type `$T$`. Otherwise, `size_of(type_of(r))`.
7574+
[#]{.pnum} *Returns*: If `r` represents a non-static data member of type `$T$`, a data member description (`$T$`, `$N$`, `$A$`, `$W$`, `$NUA$`), or `dealias(r)` represents a type `$T$`, then `sizeof($LAT$)` where `$LAT$` is the layout-associated type ([class.member.general]) of a non-static data member of type `$T$`. Otherwise, `size_of(type_of(r))`.
75747575

75757576
[It is possible that while `sizeof(char) == size_of(^^char)` that `sizeof(char&) != size_of(^^char&)`. If `b` represents a direct base class relationship of an empty base class, then `size_of(b) > 0`.]{.note}
75767577

0 commit comments

Comments
 (0)