Skip to content

Fix strict aliasing violation in the neon batch_bool load - #1420

Merged
serge-sans-paille merged 1 commit into
xtensor-stack:masterfrom
domibel:neon-batch-bool-debian-1143838
Oct 1, 2026
Merged

serge-sans-paille merged 1 commit into
xtensor-stack:masterfrom
domibel:neon-batch-bool-debian-1143838

Conversation

@domibel

@domibel domibel commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

The sizeof(T) == 4 overload read a bool const* through an unsigned int lvalue, which is undefined behaviour. Use memcpy instead.

The bug was reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1143838

Comment thread include/xsimd/arch/xsimd_neon.hpp Outdated
XSIMD_INLINE batch_bool<T, A> load_unaligned(bool const* mem, batch_bool<T, A>, requires_arch<neon>) noexcept
{
uint8x8_t tmp = vreinterpret_u8_u32(vset_lane_u32(*(unsigned int*)mem, vdup_n_u32(0), 0));
unsigned int bits;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this wasn't in the original code, but could you set uint32_t bits instead? that would match vset_lane_u32 signature more accurately

@serge-sans-paille

Copy link
Copy Markdown
Contributor

LGTM with the minor nit applied.

The sizeof(T) == 4 overload read a `bool const*` through
an `unsigned int` lvalue, which is undefined behaviour.
Use memcpy instead.
@domibel
domibel force-pushed the neon-batch-bool-debian-1143838 branch from 6aca092 to c15601e Compare October 1, 2026 06:41
@serge-sans-paille
serge-sans-paille merged commit ca2df88 into xtensor-stack:master Oct 1, 2026
88 checks passed
@serge-sans-paille

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants