[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset eebaa9bfc593d5a46b293c1abd929fbfbfd28199 by Serhiy Storchaka in branch 'master': bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release mode. (GH-16329)

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-09 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-09 Thread STINNER Victor
STINNER Victor added the comment: """ Use this when you have a code path that cannot be reached by design. For example, in the default: clause in a switch statement for which all possible values are covered in case statements. Use this in places where you might be tempted to put an

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-09 Thread STINNER Victor
STINNER Victor added the comment: The GCC documentation contains a good example: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html """ Another use for __builtin_unreachable is following a call a function that never returns but that is not declared __attribute__((noreturn)), as in this

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-09 Thread STINNER Victor
STINNER Victor added the comment: Antoine: "I agree with Serhiy. If you hit a rare situation that you don't want to handle, use Py_FatalError(), not Py_UNREACHABLE()." Py_UNREACHABLE() documentation still says "Use this when you have a code path that you do not expect to be reached." and

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2020-03-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Updated the PR according to review comments. PyNumber_ToBase() now raises SystemError for unsupported base instead of crashing. unicode_eq() asserts that unicode strings are ready (it is only called for hashed strings and if we have a hash they should be

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-10-04 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: +1 Serhiy. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-10-04 Thread STINNER Victor
STINNER Victor added the comment: > Py_UNREACHABLE() is for situations which are *logically* impossible, not just > uncommon. I suggest to clarify/enhance Py_UNREACHABLE() documentation to make it more explicit in that case. -- ___ Python

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-10-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: I agree with Serhiy. If you hit a rare situation that you don't want to handle, use Py_FatalError(), not Py_UNREACHABLE(). Py_UNREACHABLE() is for situations which are *logically* impossible, not just uncommon. -- nosy: +pitrou

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > What does __builtin_unreachable()? Does it nothing? Call abort()? It is more than does nothing. It gives a hint to the compiler, so it can optimize out checks that lead to this code. For example, in switch (k) { case 0: ... case 1: ...

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-23 Thread STINNER Victor
STINNER Victor added the comment: Ah, moreover, it's a public macro, so I would prefer to not change its behavior. I consider that modify the macro to call __builtin_unreachable() changes the behavior. -- ___ Python tracker

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-23 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-38147. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-23 Thread STINNER Victor
STINNER Victor added the comment: What does __builtin_unreachable()? Does it nothing? Call abort()? > Py_UNREACHABLE is used to indicate that a specific point in the program > cannot be reached, even if the compiler might otherwise think it can. I disagree here.

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-22 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +15905 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16329 ___ Python tracker

[issue38249] Optimize out Py_UNREACHABLE in the release mode

2019-09-22 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : Py_UNREACHABLE is used to indicate that a specific point in the program cannot be reached, even if the compiler might otherwise think it can. This is exact the case for __builtin_unreachable in GCC and Clang. I propose to extend Py_UNREACHABLE() to