r/wg21
P3932R0 - Fix LWG4470: Fix integer-from in [simd] WG21
Posted by u/paper_plumber_42 · 6 hr. ago

Document: P3932R0
Author: Matthias Kretz
Date: 2026-02-13
Audience: LWG
Target: C++26

Matthias Kretz is back with plumbing work on std::simd. Three LWG issues - 4470, 4414, and 4518 - all touch overlapping wording in [simd], so they get fixed together in one paper.

The main issue: integer-from<Bytes>, an exposition-only trait used throughout the simd spec, broke when complex became a vectorizable type. Now Bytes can be 16, and nobody wants to require a 128-bit signed integer type from conforming implementations. The paper reworks how masks and ABI tags are specified to avoid depending on integer-from where it doesn't work.

Along the way, simd::cat gets a fix so that round-tripping through chunk/cat preserves your ABI tag instead of silently converting, and deduce-abi-t gets clarified for out-of-range arguments.

▲ 28 points (85% upvoted) · 7 comments
sorted by: best
u/constexpr_everything_2024 24 points 5 hr. ago

wording fixes already rolling in for std::simd and most of us haven't even touched the API yet. Kretz works fast.

u/simd_lane_zero 14 points 2 hr. ago

Section 2.2 is the interesting one. The paper shows this scenario:

basic_vec x = ...;
auto [...vs] = simd::chunk<2>(x);
auto y = simd::cat(vs...);
static_assert(is_same_v<decltype(x), decltype(y)>); // can fail

So chunk followed by cat doesn't round-trip to the same type because the return type was using deduce-abi-t instead of resize_t. The fix picks the first argument's ABI tag. Simple and deterministic. You could argue for other heuristics - widest argument, most common tag - but for a defect fix this is the pragmatic choice.

Also notable: the paper recommends no feature test macro bump despite behavioral changes.

It was not intended to require conforming implementations to now provide a 128-bit signed integer type.

Fair enough for exposition-only traits. But anyone whose simd::cat return type silently changed might want a way to detect the fix at compile time.

u/just_a_numerics_guy 11 points 4 hr. ago

Wait, std::complex<double> is a vectorizable type in C++26? I've been writing SIMD intrinsics for over a decade and somehow missed that going into P1928.

u/template_trauma_survivor 7 points 3 hr. ago

It was added pretty late in the P1928 lifecycle. From the paper:

After the introduction of complex to the set of vectorizable types, the integer-from trait does not work as intended anymore.

Pretty much exactly what happens when you expand a type set right before shipping. sizeof(complex<double>) is 16 and the old integer-from<16> expected a signed integer type that doesn't exist in the standard.

u/stdlib_when_though 5 points 1 hr. ago

genuinely curious where implementations stand. is any standard library shipping conforming std::simd yet or is everyone still on experimental?

u/constexpr_everything_2024 6 points 42 min. ago

libstdc++ has had std::experimental::simd for years - Kretz literally wrote it. libc++ has a partial implementation going. MSVC I'm less sure about. The gap between spec and shipping is still wide.

u/daily_intrinsics_enjoyer 3 points 28 min. ago

three issues, one paper, zero controversy. this is what LWG work looks like when it works.