|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4113" status="New"> |
| 5 | +<title>Disallow <code>has_unique_object_representations<Incomplete[]></code></title> |
| 6 | +<section><sref ref="[meta.unary.prop]"/></section> |
| 7 | +<submitter>Jonathan Wakely</submitter> |
| 8 | +<date>25 Jun 2024</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +The type completeness requirements for `has_unique_object_representations` say: |
| 14 | +<blockquote> |
| 15 | +`T` shall be a complete type, <i>cv</i> `void`, or an array of unknown bound. |
| 16 | +</blockquote> |
| 17 | +</p> |
| 18 | +<p> |
| 19 | +This implies that the trait works for all arrays of unknown bound, |
| 20 | +whether the element type is complete or not. That seems to be incorrect, |
| 21 | +because <code>has_unique_object_representations_v<Incomplete[]></code> |
| 22 | +is required to have the same result as |
| 23 | +<code>has_unique_object_representations_v<Incomplete></code> |
| 24 | +which is ill-formed if `Incomplete` is an incomplete class type. |
| 25 | +</p> |
| 26 | + |
| 27 | +<p> |
| 28 | +I think we need the element type to be complete to be able to give an answer. |
| 29 | +Alternatively, if the intended result for an array of unknown bound is false |
| 30 | +(maybe because there can be no objects of type `T[]`, or because we can't |
| 31 | +know that two objects declared as `extern T a[];` and `extern T b[];` have |
| 32 | +the same number of elements?) then the condition for the trait needs to be |
| 33 | +special-cased as `false` for arrays of unknown bound. |
| 34 | +The current spec is inconsistent, we can't allow arrays of unknown bound |
| 35 | +and apply the current rules to determine the trait's result. |
| 36 | +</p> |
| 37 | +</discussion> |
| 38 | + |
| 39 | +<resolution> |
| 40 | +<p> |
| 41 | +This wording is relative to <paper num="N4981"/>. |
| 42 | +</p> |
| 43 | + |
| 44 | +<ol> |
| 45 | +<li><p>Modify <sref ref="[meta.unary.prop]"/> as indicated:</p> |
| 46 | + |
| 47 | +<blockquote> |
| 48 | +<table style="border: 1px solid; border-spacing: 1.5em"> |
| 49 | +<thead style="text-align: center"> |
| 50 | +<tr><th>Template</th><th>Condition</th><th>Preconditions</th></tr> |
| 51 | +</thead> |
| 52 | +<tbody style="vertical-align: top"> |
| 53 | +<tr><td>…</td><td>…</td><td>…</td></tr> |
| 54 | +<tr> |
| 55 | +<td> |
| 56 | +<pre><code>template<class T> |
| 57 | +struct has_unique_object_representations;</code></pre> |
| 58 | +</td> |
| 59 | +<td> |
| 60 | +For an array type `T`, the same result as |
| 61 | +<code>has_unique_object_representations_v<remove_all_extents_t<T>></code>, |
| 62 | +otherwise <i>see below</i>. |
| 63 | +</td> |
| 64 | +<td> |
| 65 | +<ins><code>remove_all_extents_t<T></code></ins> |
| 66 | +<del><code>T</code></del> |
| 67 | +shall be a complete type<del>,</del> |
| 68 | +<ins>or</ins> <i>cv</i> `void`<del>, or an array of unknown bound</del>. |
| 69 | +</td> |
| 70 | +</tr> |
| 71 | +</tbody> |
| 72 | +</table> |
| 73 | +</blockquote> |
| 74 | +<blockquote class="note"> |
| 75 | +<p> |
| 76 | +[<i>Drafting note</i>: We could use <code>remove_extent_t<T></code> |
| 77 | +to remove just the first array dimension, because only that first one can |
| 78 | +have an unknown bound. |
| 79 | +The proposed resolution uses <code>remove_all_extents_t<T></code> |
| 80 | +for consistency with the <b>Condition</b> column.] |
| 81 | +</p> |
| 82 | +</blockquote> |
| 83 | + |
| 84 | +</li> |
| 85 | +</ol> |
| 86 | +</resolution> |
| 87 | + |
| 88 | +</issue> |
0 commit comments