intel-intrinsics
intel-intrinsics copied to clipboard
Safety-washing
Function that takes a pointer which is then accessed too greedily should be @system
. This is breaking unfortunately.
Find and fix all such functions that either cast a pointer to __m128*
,__m128i*
, __m128d*
, or assume alignment.
To be clear:
- this is @safe:
float readOne(float* adr) @safe
{
return *adr;
}
In D "memory safety" doesn't include null-safety.
- this should be
@system
__m128 _mm_load_ps(const(float)*p) pure @trusted
{
return *cast(__m128*)p;
}
Rules from Adam:
so trusted functions are not supposed to depend on their arguments from the outside to be memory safe or not trusted should be self-contained and do any necessary checks it needs on its args inside itself if you rely on the caller doing the right thing, that means you are system (unless the argument is guaranteed correct by its type signature)
Does D @safety
includes "lack memory error caused by misaligned load"?
Also: same but with purity. Function that depend on, or change the rounding mode perhaps shouldn't be marked pure.
As a frst step, none of the newly introduced intrinsics are incorrectly labelled