Skip to content

AVX stream intrinsics signatures are incorrect, maybe unsound #575

Closed
@gnzlbg

Description

@gnzlbg

In the intel intrinsics guide, the signature is:

void _mm256_stream_si256 (__m256i * mem_addr, __m256i a)

but in Rust the signature is:

pub unsafe fn _mm256_stream_si256(mem_addr: *const __m256i, a: __m256i)

Note that the mem_addr pointer is const in Rust, but not in C. Since the only purpose of this function is to write through this pointer, it is probably unsound for it to take a const pointer.

EDIT: _mm256_stream_pd and _mm256_stream_ps also have this same issue. The SSE _mm_stream_ps, _mm_stream_pd, and _mm_stream_pi intrinsics correctly use *mut here.

A tangential bug is that the intrinsic verification failed hard here, since the C intrinsics do not use const pointers, it would have been safer to require these intrinsics to use mut pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions