Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safety-washing #62

Open
p0nce opened this issue Dec 20, 2020 · 4 comments
Open

Safety-washing #62

p0nce opened this issue Dec 20, 2020 · 4 comments

Comments

@p0nce
Copy link
Collaborator

p0nce commented Dec 20, 2020

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.

@p0nce
Copy link
Collaborator Author

p0nce commented Dec 20, 2020

To be clear:

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)

@p0nce
Copy link
Collaborator Author

p0nce commented Dec 21, 2020

Does D @safety includes "lack memory error caused by misaligned load"?

@p0nce p0nce added the question label Dec 21, 2020
@p0nce
Copy link
Collaborator Author

p0nce commented Aug 9, 2021

Also: same but with purity. Function that depend on, or change the rounding mode perhaps shouldn't be marked pure.

p0nce pushed a commit that referenced this issue Aug 30, 2022
@p0nce
Copy link
Collaborator Author

p0nce commented Feb 25, 2023

As a frst step, none of the newly introduced intrinsics are incorrectly labelled

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

No branches or pull requests

1 participant