Skip to content

Commit 79720b2

Browse files
committed
New issue from Matthias Kretz: "simd broadcast is overconstrained — std::cw<0.f> is not convertible to simd::vec<float16_t>"
1 parent d9e637c commit 79720b2

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

xml/issue4436.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4436" status="New">
5+
<title>`simd` broadcast is overconstrained &mdash; <tt>std::cw&lt;0.f&gt;</tt> is not convertible to <tt>simd::vec&lt;float16_t&gt;</tt></title>
6+
<section><sref ref="[simd.ctor]"/></section>
7+
<submitter>Matthias Kretz</submitter>
8+
<date>28 Oct 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
<sref ref="[simd.ctor]"/> p4 requires all implicit conversions via broadcast
14+
constructor to satisfy <tt>convertible_to&lt;value_type&gt;</tt>. However,
15+
<tt>std::cw&lt;0.f&gt;</tt> is not convertible to `float16_t` because `float`
16+
does not satisfy <tt>convertible_to&lt;float16_t&gt;</tt>. Consequently, with
17+
the current wording we don't arrive at bullet (4.3) which allows
18+
not-value-preserving conversions if the value is known to not change on conversion.
19+
The `convertible_to` constraint is implicit in bullet (4.2), not needed/wrong for
20+
bullet (4.3) and thus needs to be moved into bullet (4.1).
21+
</p>
22+
</discussion>
23+
24+
<resolution>
25+
<p>
26+
This wording is relative to <paper num="N5014"/>.
27+
</p>
28+
29+
<ol>
30+
31+
<li><p>Modify <sref ref="[simd.ctor]"/> as indicated:</p>
32+
33+
<blockquote>
34+
<pre>
35+
template&lt;class U&gt; constexpr explicit(<i>see below</i>) basic_vec(U&amp;&amp; value) noexcept;
36+
</pre>
37+
<blockquote>
38+
<p>
39+
-1- Let `From` denote the type <tt>remove_cvref_t&lt;U&gt;</tt>.
40+
<p/>
41+
-2- <i>Constraints</i>: `value_type` satisfies <tt>constructible_from&lt;U&gt;</tt>.
42+
<p/>
43+
-3- <i>Effects</i>: Initializes each element to the value of the argument after conversion to `value_type`.
44+
<p/>
45+
-4- <i>Remarks</i>: The expression inside explicit evaluates to `false` if and only if <del>`U` satisfies
46+
<tt>convertible_to&lt;value_type&gt;</tt>, and</del> either
47+
</p>
48+
<ul style="list-style-type: none">
49+
<li>(4.1) &mdash;
50+
<ins>`U` satisfies <tt>convertible_to&lt;value_type&gt;</tt> and</ins> `From` is not an arithmetic type
51+
and does not satisfy <tt><i>constexpr-wrapper-like</i></tt>,
52+
</li>
53+
<li>(4.2) &mdash;
54+
`From` is an arithmetic type and the conversion from `From` to `value_type` is value-preserving
55+
(<sref ref="[simd.general]"/>), or
56+
</li>
57+
<li>(4.3) &mdash;
58+
`From` satisfies <tt><i>constexpr-wrapper-like</i></tt>, <tt>remove_const_t&lt;decltype(From::value)&gt;</tt>
59+
is an arithmetic type, and `From::value` is representable by `value_type`.
60+
</li>
61+
</ul>
62+
63+
</blockquote>
64+
</blockquote>
65+
</li>
66+
</ol>
67+
68+
</resolution>
69+
70+
</issue>

0 commit comments

Comments
 (0)