Title
`simd::basic_vec` CTAD misses difference type casting
Status
new
Section
[simd.ctor]
Submitter
Hewill Kang

Created on 2025-10-04.00:00:00 last changed 1 week ago

Messages

Date: 2025-10-04.14:28:02

Proposed resolution:

This wording is relative to N5014.

  1. Modify [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))>

Date: 2025-10-04.00:00:00

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.

History
Date User Action Args
2025-10-04 14:28:02adminsetmessages: + msg15124
2025-10-04 00:00:00admincreate