P4012R0 — value-preserving consteval broadcast to simd::vec
(6 items)
LEWG, LWG
This paper proposes adding a consteval broadcast constructor overload to std::simd's basic_vec that enables value-preserving implicit conversions from arithmetic types like int, restoring behavior from the Parallelism 2 TS that was lost in the C++26 Committee Draft. The consteval overload is constrained to types that are not already value-preserving-convertible to the target type, and uses constexpr exceptions to make value-changing conversions ill-formed at compile time. A secondary alternative of simply removing explicit conversion on broadcast is also presented as a fallback to preserve design space for C++29.
- Section 10.4, p. 9 — The consteval constructor declaration in the class synopsis ([simd.overview]) is missing a terminating semicolon; all other declarations in the same synopsis have one. [1]
- Section 10.5, p. 10 — The consteval constructor declaration heading in the specification ([simd.ctor]) is missing a terminating semicolon. [3] [2]
- Section 10.5, p. 10 — Stable name "[simd.ctore]" does not exist; should be "[simd.ctor]". [1] [3]
- Section 11.3, p. 11 — Stable name "[simd.ctore]" does not exist; should be "[simd.ctor]". [2] [4]
- Section 5 (Motivation), p. 4 — "instantations" is misspelled; should be "instantiations". [5]
- Section 5 (Motivation), p. 3 — "it's" (contraction) used where possessive "its" is required. [6]
References — Anthropic Citations API
[1]
"P4012R0 11 Wording for removing explicit conversion on broadcast 10.5 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template U>
constexpr..."
"P4012R0 11 Wording for removing explicit conversion on broadcast 10.5 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
[1]
"P4012R0 A really_convertible_to definition 11.3 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
constexpr explicit(see below) basic_vec(U&& value) noexcept;
5 Let..."
"P4012R0 A really_convertible_to definition 11.3 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
[2]
"P4012R0 11 Wording for removing explicit conversion on broadcast 10.5 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template U>
constexpr..."
"P4012R0 11 Wording for removing explicit conversion on broadcast 10.5 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
[2]
"P4012R0 A really_convertible_to definition 11.3 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
constexpr explicit(see below) basic_vec(U&& value) noexcept;
5 Let..."
"P4012R0 A really_convertible_to definition 11.3 modify [simd.ctor] In [simd.ctore], change: [simd.ctor] template
[3]
"template U>
consteval basic_vec(U&& x)
template"
"template
[4]
"template U> consteval basic_vec(U&& x)
-?- Preconditions: The value of x is equal to the value of x after conversion to value_type.
"
"template
[5]
"However, V(0x5EAF00D) is shorter and needs fewer template instantations."
"However, V(0x5EAF00D) is shorter and needs fewer template instantations."
[6]
"a basic_vec broadcast constructor (with it's helper types/concepts to determine whether the specialization is allowed)"
"a basic_vec broadcast constructor (with it's helper types/concepts to determine whether the specialization is allowed)"
Summary: P4012R0 proposes making the broadcast constructor of simd::basic_vec a consteval function so that narrowing or non-value-preserving conversions from scalar to vector element type are diagnosed at compile time rather than silently truncating. It also removes the explicit qualifier from the broadcast constructor for consteval-safe argument types. Six defects were found in the proposed wording and motivational text.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.