Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Sep 19, 2019

Use Py_UNREACHABLE() macro in a safe way.

https://bugs.python.org/issue38205

Use Py_UNREACHABLE() macro in a safe way.

/* If use inline functions here, may lose performance due to
unnecessary type casting. */
#define IS_SMALL_INT(ival) (-NSMALLNEGINTS <= (ival) && (ival) < NSMALLPOSINTS)
Copy link
Author

Choose a reason for hiding this comment

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

Address STINNER Victor's advice:

Morever, if using a static inline function is causing issues, it would be nice to add a comment to explain why, so the issue will be avoided in the future.
https://bugs.python.org/issue37812#msg352670

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

" bpo-38205: replace get_small_int(ival) macro with a function version #16270 "

Wait, https://bugs.python.org/issue38205 is about a macro which became a function and then was revert to a macro again... I don't understand why you make it a function... one more time.

Py_UNREACHABLE() should be fixed, not longobject.c.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ghost
Copy link
Author

ghost commented Sep 19, 2019

I like the idea of implementing Py_UNREACHABLE() as a function.

+1, close this PR.

@ghost ghost closed this Sep 19, 2019
@ghost
Copy link
Author

ghost commented Sep 19, 2019

I don't understand why you make it a function... one more time.

The current code is not consistent:
If "preallocated small integers" enalbed, get_small_int(ival) is a function.
If "preallocated small integers" disabled, get_small_int(ival) is a macro.

@ghost ghost deleted the unreachable branch September 20, 2019 02:47
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants