-
Notifications
You must be signed in to change notification settings - Fork 25.6k
suppress -Wcast-function-type-strict
when casting to PyCFunction
#100068
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/100068
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c680b75: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
-Wcast-function-type-strict
when casting to PyCFunction-Wcast-function-type-strict
when casting to PyCFunction
Summary: These casts are a necessary evil due to the design of Python. Python ultimately casts it back to the original type based on the flags specified in the `PyMethodDef`. Nevertheless, the new Clang flag `-Wcast-function-type-strict` breaks with this. While here, convert the cast to a `reinterpret_cast`. Test Plan: Should be a no-op. Rely on CI.
-Wcast-function-type-strict
when casting to PyCFunction
-Wcast-function-type-strict
when casting to PyCFunction
@pytorchbot merge |
return (PyCFunction)(void (*)(void))func; | ||
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type") | ||
C10_DIAGNOSTIC_PUSH_AND_IGNORED_IF_DEFINED("-Wcast-function-type-strict") | ||
return reinterpret_cast<PyCFunction>(func); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cannot be a static_cast right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. The pointer types are unrelated and neither is void*.
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
suppress
-Wcast-function-type-strict
when casting to PyCFunctionSummary:
These casts are a necessary evil due to the design of Python. Python
ultimately casts it back to the original type based on the flags
specified in the
PyMethodDef
.Nevertheless, the new Clang flag
-Wcast-function-type-strict
breakswith this.
While here, convert the cast to a
reinterpret_cast
.Test Plan: Should be a no-op. Rely on CI.