Title
`simd` broadcast is overconstrained — std::cw<0.f> is not convertible to simd::vec<float16_t>
Status
new
Section
[simd.ctor]
Submitter
Matthias Kretz

Created on 2025-10-28.00:00:00 last changed 5 days ago

Messages

Date: 2026-01-16.15:25:05

Proposed resolution:

This wording is relative to N5014.

  1. Modify [simd.ctor] as indicated:

    template<class U> constexpr explicit(see below) basic_vec(U&& value) noexcept;
    

    -1- Let `From` denote the type remove_cvref_t<U>.

    -2- Constraints: `value_type` satisfies constructible_from<U>.

    -3- Effects: Initializes each element to the value of the argument after conversion to `value_type`.

    -4- Remarks: The expression inside explicit evaluates to `false` if and only if `U` satisfies convertible_to<value_type>, and either

    • (4.1) — `U` satisfies convertible_to<value_type> and `From` is not an arithmetic type and does not satisfy constexpr-wrapper-like,
    • (4.2) — `From` is an arithmetic type and the conversion from `From` to `value_type` is value-preserving ([simd.general]), or
    • (4.3) — `From` satisfies constexpr-wrapper-like, remove_const_t<decltype(From::value)> is an arithmetic type, and `From::value` is representable by `value_type`.
Date: 2026-01-15.00:00:00

[ 2026-01-16; Reflector poll. ]

Set priority to 1 after reflector poll.

"Resolution should be rebased on LWG 4420, constraint was already changed to not use `constructible_from`. Might as well drive-by fix 4.3 to use `remove_cvref_t` so it works for `constant_wrapper`.

Date: 2025-10-28.00:00:00

[simd.ctor] p4 requires all implicit conversions via broadcast constructor to satisfy convertible_to<value_type>. However, std::cw<0.f> is not convertible to `float16_t` because `float` does not satisfy convertible_to<float16_t>. Consequently, with the current wording we don't arrive at bullet (4.3) which allows not-value-preserving conversions if the value is known to not change on conversion. The `convertible_to` constraint is implicit in bullet (4.2), not needed/wrong for bullet (4.3) and thus needs to be moved into bullet (4.1).

History
Date User Action Args
2026-01-16 15:25:05adminsetmessages: + msg15855
2025-10-31 10:39:22adminsetmessages: + msg15473
2025-10-28 00:00:00admincreate