|
| 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 — <tt>std::cw<0.f></tt> is not convertible to <tt>simd::vec<float16_t></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<value_type></tt>. However, |
| 15 | +<tt>std::cw<0.f></tt> is not convertible to `float16_t` because `float` |
| 16 | +does not satisfy <tt>convertible_to<float16_t></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<class U> constexpr explicit(<i>see below</i>) basic_vec(U&& value) noexcept; |
| 36 | +</pre> |
| 37 | +<blockquote> |
| 38 | +<p> |
| 39 | +-1- Let `From` denote the type <tt>remove_cvref_t<U></tt>. |
| 40 | +<p/> |
| 41 | +-2- <i>Constraints</i>: `value_type` satisfies <tt>constructible_from<U></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<value_type></tt>, and</del> either |
| 47 | +</p> |
| 48 | +<ul style="list-style-type: none"> |
| 49 | +<li>(4.1) — |
| 50 | +<ins>`U` satisfies <tt>convertible_to<value_type></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) — |
| 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) — |
| 58 | +`From` satisfies <tt><i>constexpr-wrapper-like</i></tt>, <tt>remove_const_t<decltype(From::value)></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