Skip to content
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ static uintptr_t return_pointer_as_int(char* p) {
}
#endif

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4172)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use _AddressOfReturnAddress and avoid the UB on Windows?

https://learn.microsoft.com/en-us/cpp/intrinsics/addressofreturnaddress?view=msvc-170

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - even better!

See https://godbolt.org/z/7c9Gq9jzM, that should work out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it works on Windows arm64 too.

static inline uintptr_t
_Py_get_machine_stack_pointer(void) {
#if _Py__has_builtin(__builtin_frame_address)
Expand All @@ -209,6 +213,9 @@ _Py_get_machine_stack_pointer(void) {
return return_pointer_as_int(&here);
#endif
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif

static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
uintptr_t here_addr = _Py_get_machine_stack_pointer();
Expand Down
Loading