This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4436. simd broadcast is overconstrained — std::cw<0.f> is not convertible to simd::vec<float16_t>

Section: 29.10.7.2 [simd.ctor] Status: New Submitter: Matthias Kretz Opened: 2025-10-28 Last modified: 2025-10-31

Priority: Not Prioritized

View other active issues in [simd.ctor].

View all other issues in [simd.ctor].

View all issues with New status.

Discussion:

29.10.7.2 [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).

Proposed resolution:

This wording is relative to N5014.

  1. Modify 29.10.7.2 [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 (29.10.1 [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.