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.

4403. simd::basic_vec CTAD misses difference type casting

Section: 29.10.7.2 [simd.ctor] Status: New Submitter: Hewill Kang Opened: 2025-10-04 Last modified: 2025-10-04

Priority: Not Prioritized

View other active issues in [simd.ctor].

View all other issues in [simd.ctor].

View all issues with New status.

Discussion:

Currently, basic_vec can take an object r of range type R whose size is a constant expression and deduced to vec<ranges::range_value_t<R>, ranges::size(r)>.

However, such a deduced type is ill-formed when R has a an integer-class type size which cannot be implicitly converted to simd-size-type, which is a signed integer type.

It is necessary to perform difference type casting here, and the narrowing conversion will still correctly be rejected due to the constructor's constraints.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 29.10.7.2 [simd.ctor] as indicated:

    template<class R, class... Ts>
      basic_vec(R&& r, Ts...) -> see below;
    

    -17- Constraints:

    1. (17.1) — R models ranges::contiguous_range and ranges::sized_range, and

    2. (17.2) — ranges::size(r) is a constant expression.

    -18- Remarks: The deduced type is equivalent to vec<ranges::range_value_t<R>, static_cast<simd-size-type>(ranges::size(r))>