Skip to content

Avoid casting for unrelated types #140

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions libdivide.h
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,8 @@ int16_t libdivide_s16_recover(const struct libdivide_s16_t *denom) {
}

int16_t libdivide_s16_branchfree_recover(const struct libdivide_s16_branchfree_t *denom) {
return libdivide_s16_recover((const struct libdivide_s16_t *)denom);
const struct libdivide_s16_t den = {denom->magic, denom->more};
return libdivide_s16_recover(&den);
}

/////////// SINT32
Expand Down Expand Up @@ -1564,7 +1565,8 @@ int32_t libdivide_s32_recover(const struct libdivide_s32_t *denom) {
}

int32_t libdivide_s32_branchfree_recover(const struct libdivide_s32_branchfree_t *denom) {
return libdivide_s32_recover((const struct libdivide_s32_t *)denom);
const struct libdivide_s32_t den = {denom->magic, denom->more};
return libdivide_s32_recover(&den);
}

///////////// SINT64
Expand Down Expand Up @@ -1728,7 +1730,8 @@ int64_t libdivide_s64_recover(const struct libdivide_s64_t *denom) {
}

int64_t libdivide_s64_branchfree_recover(const struct libdivide_s64_branchfree_t *denom) {
return libdivide_s64_recover((const struct libdivide_s64_t *)denom);
const struct libdivide_s64_t den = {denom->magic, denom->more};
return libdivide_s64_recover(&den);
}

// Simplest possible vector type division: treat the vector type as an array
Expand Down